Using LocalTime for Time Manipulation in Java


LocalTime is part of the Java 8 Date and Time API that represents time without a date.

Source Code

LocalTime now = LocalTime.now();
LocalTime sixThirty = LocalTime.of(6, 30);
LocalTime sevenThirty = sixThirty.plus(1, ChronoUnit.HOURS);
System.out.println("Now: " + now);
System.out.println("Six Thirty: " + sixThirty);
System.out.println("Seven Thirty: " + sevenThirty);
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments