将毫秒格式化为SimpleDate格式时,我遇到了一个奇怪的结果:
输出是:
Start date time: 11/06/30 09:45:48:970
End date time: 11/06/30 09:45:52:831
Execution time: 01:00:03:861
脚本:
long dateTimeStart = System.currentTimeMillis();
// some script execution here
long dateTimeEnd = System.currentTimeMillis();
"Start date time: " + GlobalUtilities.getDate(dateTimeStart,"yy/MM/dd hh:mm:ss:SSS");
"End date time: " + GlobalUtilities.getDate(dateTimeEnd,"yy/MM/dd hh:mm:ss:SSS");
"Execution time: " + GlobalUtilities.getDate((dateTimeEnd - dateTimeStart),"hh:mm:ss:SSS");
方法:
public static String getDate(long milliseconds,String format)
{
SimpleDateFormat sdf = new SimpleDateFormat(format);
return sdf.format(milliseconds);
}
知道为什么执行时间值如此偏离?它应该是00:00:03:861,而不是01:00:03:861
谢谢
最佳答案