I would prefer to use suggested java.util.concurrent.TimeUnit
class.
long diff = d2.getTime() - d1.getTime();//as given
long seconds = TimeUnit.MILLISECONDS.toSeconds(diff);
long minutes = TimeUnit.MILLISECONDS.toMinutes(diff);
More Related Contents:
- Sort Arraylist With Times [duplicate]
- How do I measure time elapsed in Java? [duplicate]
- How to convert Milliseconds to “X mins, x seconds” in Java?
- What is this date format? 2011-08-12T20:17:46.384Z
- How to calculate “time ago” in Java?
- Convert timestamp in milliseconds to string formatted time in Java
- Time comparison
- JFormattedTextField : input time duration value
- Creating java date object from year,month,day
- Best way to constrain user to enter a time in a JTextField
- System.currentTimeMillis() vs. new Date() vs. Calendar.getInstance().getTime()
- Extract time from date String
- Calculating the difference between two Java date instances
- Java: getMinutes and getHours
- Java Date cut off time information
- How do I calculate the elapsed time of an event in Java? [duplicate]
- Calculate Difference between two times in Android
- How to properly format the date?
- How do you have the code pause for a couple of seconds in android?
- Why is System.nanoTime() way slower (in performance) than System.currentTimeMillis()?
- How to transform currentTimeMillis to a readable date format? [duplicate]
- How to extract epoch from LocalDate and LocalDateTime?
- java.lang.System.currentTimeMillis() replace method
- Find total hours between two Dates
- Android get Current UTC time [duplicate]
- Time: How to get the next friday?
- Get the number of days, weeks, and months, since Epoch in Java
- How can I measure time with microsecond precision in Java?
- CPU execution time in Java
- How can I find the amount of seconds passed from the midnight with Java?