Tutorialspoint

Java Program to convert java.util.Date to java.time.LocalDateTime

import java.time.ZoneId;
import java.util.Date;
public class Demo {
	public static void main(String[] args) {
		java.util.Date  date = new Date();
		System.out.println("Date = "+date);
		java.time.LocalDateTime dateTime = java.time.LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
		System.out.println("LocalDateTime = "+dateTime);
	}
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.