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);

One Reply to “Elapsed time between two java.time.LocalDateTime instances”

Leave a Reply

Your email address will not be published. Required fields are marked *

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