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()); } }
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more