LocalDateTime for Date and Time in Java


LocalDateTime combines date and time, useful for more detailed time stamps.

Source Code

LocalDateTime now = LocalDateTime.now();
LocalDateTime inTwoHours = now.plusHours(2);
System.out.println("Now: " + now); // Outputs current date and time
System.out.println("In two hours: " + inTwoHours); // Outputs date and time two hours from now
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments