Here you can find the source of getTimeDifference(Timestamp startTime, Timestamp endTime)
Parameter | Description |
---|---|
startTime | the start time |
endTime | the end time |
public static String getTimeDifference(Timestamp startTime, Timestamp endTime)
//package com.java2s; import java.sql.Timestamp; public class Main { /**/* w w w. ja v a2 s . c om*/ * Gets the time difference. * * @param startTime * the start time * @param endTime * the end time * @return the time difference */ public static String getTimeDifference(Timestamp startTime, Timestamp endTime) { long timeInMilliseconds = endTime.getTime() - startTime.getTime(); int seconds = (int) (timeInMilliseconds / 1000); int minutes = seconds / 60; int milliseconds = (int) (timeInMilliseconds % 1000); return minutes + " minute(s) " + seconds + " second(s) " + milliseconds + " millisecond(s)"; } }