public class Program {
public static void main(String args[]) {
LocalDateTime sylvester = LocalDateTime.of(2014, Month.DECEMBER, 31, 23, 59, 59);
DayOfWeek dayOfWeek = sylvester.getDayOfWeek();
System.out.println(dayOfWeek); // WEDNESDAY
Month month = sylvester.getMonth();
System.out.println(month); // DECEMBER
long minuteOfDay = sylvester.getLong(ChronoField.MINUTE_OF_DAY);
System.out.println(minuteOfDay); // 1439
Instant instant = sylvester
.atZone(ZoneId.of("America/New_York"))
.toInstant();
System.out.println("This is the instant " + instant);
//This for each will print the list of available time zones to be used similarlly to the above "America/New_York"
for (String timeZoneID : TimeZone.getAvailableIDs()) {
System.out.println(timeZoneID);
}
Date legacyDate = Date.from(instant);
System.out.println(legacyDate); // Wed Dec 31 20:59:59 PST 2014
DateTimeFormatter formatter =
DateTimeFormatter
.ofPattern("MMM dd, yyyy - HH:mm");
LocalDateTime parsed = LocalDateTime.parse("Nov 03, 2014 - 07:13", formatter);
String string = parsed.format(formatter);
System.out.println(string); // Nov 03, 2014 - 07:13
}
}