日期:2014-05-18 浏览次数:20732 次
long tm = (Calendar.getInstance().getTimeInMillis() - date2.getTime()); int ms = (int)(tm%1000); tm /= 1000; int sc = (int)(tm%60); tm /= 60; int mn = (int)(tm%60); tm /= 60; int hr = (int)(tm%24); long dy = tm/24; String useTime = dy+"天"+hr+"小时"+mn+"分"+sc+"."+ms+"秒";
------解决方案--------------------
我亲自测试过了!可以!
public static void main(String[] args)
{
Date date = new Date();
String num = "2009-6-10";
try{
Date m_endTime = new java.text.SimpleDateFormat("yyyy-MM-dd").parse("2009-6-10");
System.out.println((date.getTime()- m_endTime.getTime())/86400000);
}catch(Exception ex){
ex.printStackTrace();
}
}
------解决方案--------------------
SELECT DATEDIFF(day, 日期字段, GetDate()) from 表名
------解决方案--------------------