Elapsed time between two java.time.LocalDateTime instances

java.time APIs provide many common date and time calculations. To calculate the elapsed time between two LocalDateTime instances you can use:

LocalDateTime start = LocalDateTime.now();
//some time inbetween
LocalDateTime end = LocalDateTime.now();

long elapsedMinutes = ChronoUnit.MINUTES.between(start, end);

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.