我只是做兩個不同的日曆兩個timemilisseconds簡單的區別。日曆之間的java差異
實施例:
Calendar ini = Calendar.getInstance();
try {
Thread.sleep(1500);
} catch (InterruptedException e) {e.printStackTrace();}
Calendar end = Calendar.getInstance();
long diff = end.getTimeInMillis()-ini.getTimeInMillis();
System.out.println("diff "+diff);
System.out.println("ini date "+ ini.getTime());
System.out.println("end date "+ end.getTime());
System.out.println("diff time format "+timeFormat.format(diff));
時間的格式爲:
private final static String TIME_STRING_FORMAT = "hh:mm:ss.SSS";
private static SimpleDateFormat timeFormat = new SimpleDateFormat(TIME_STRING_FORMAT);
,並在輸出,總是出現1我們的差異,是它的的SimpleDateFormat的問題???
輸出:
diff 1500
ini date Sun May 24 22:27:01 CEST 2015
end date Sun May 24 22:27:03 CEST 2015
diff time format 01:00:01.500
感謝您的幫助!
我不知道任何'SimpleDateFormat#format'重載接收'long'解析。請提供確切的代碼來複制您的問題。 –