Java examples for java.util:Millisecond
get Milli Difference Between Time
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Locale; public class Main { private static SimpleDateFormat sdf_Full = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss:SSS", Locale.CHINA); public static int getMilliDifferenceBetweenTime(String start) { Calendar c1 = Calendar.getInstance(); Calendar c2 = Calendar.getInstance(); try {/* w w w . ja v a 2s . co m*/ c1.setTime(sdf_Full.parse(start)); c2.setTime(sdf_Full.parse(getCurrentTimeFull())); return (int) Math.abs(c1.getTimeInMillis() - c2.getTimeInMillis()); } catch (ParseException pe) { return 0; } } public static String getCurrentTimeFull() { return sdf_Full.format(new Date()); } }