Here you can find the source of getDurationMillisecond(Date date1, Date date2)
public static long getDurationMillisecond(Date date1, Date date2)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { private static final String TIME_FORMAT = "HH:mm:ss"; private static SimpleDateFormat sFormat; public static long getDurationMillisecond(Date date1, Date date2) { return date2.getTime() - date1.getTime(); }// w w w . j a va2s.c o m public static String getTime(Date date) { sFormat = new SimpleDateFormat(TIME_FORMAT, Locale.CHINA); return sFormat.format(date); } public static String getTime() { return getTime(new Date()); } }