Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.Date; public class Main { /** * elapsedTimeDisplay * Get the elapsed time between two dates in readable format * * @param dateStart the date start * @param dateEnd the date end * @return the elapsed hours and minutes */ public static String elapsedTimeDisplay(Date dateStart, Date dateEnd) { long diff = dateEnd.getTime() - dateStart.getTime(); long diffMinutes = diff / (60 * 1000) % 60; long diffHours = diff / (60 * 60 * 1000); String mins = Long.toString(diffMinutes); if (mins.length() == 1) { mins = "0" + mins; } return Long.toString(diffHours) + ":" + mins; } }