java 计算时间差
DateFormat df = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”);
try
{
Date d1 = df.parse(“2004-03-26 13:31:40”);
Date d2 = df.parse(“2004-01-02 11:30:24”);
long diff = d1.getTime() – d2.getTime(); //毫秒数
long days = diff / (1000 * 60 * 60 * 24); //天
}
catch (Exception e)
{
}
分类: java 2,649 次阅读
原文链接:http://www.wenhq.com/article/view_220.html欢迎转载,请注明出处:亲亲宝宝