Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Java Program to convert java.util.Date to any local date

import java.time.ZoneId;
import java.util.Date;
public class Demo {
	public static void main(String[] args) {
		Date date = new Date();
		ZoneId zone = ZoneId.systemDefault();
		System.out.println("LocalDate = "+date.toInstant().atZone(zone).toLocalDate());
		System.out.println("LocalTime= "+date.toInstant().atZone(zone).toLocalTime());
		System.out.println("Hour = "+date.toInstant().atZone(zone).getHour());
		System.out.println("Minute = "+date.toInstant().atZone(zone).getMinute());
		System.out.println("Seconds = "+date.toInstant().atZone(zone).getSecond());
	}
}

Advertisements
Loading...

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