日期:2014-05-17 浏览次数:20618 次
public static void main(String[] args) throws Exception {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Date d1 = df.parse("2013-8-28 11:21");
Date d2 = df.parse("2013-8-28 14:11");
long diff = d1.getTime() - d2.getTime();
long hour3 = diff / (1000 * 60 * 60 * 3);
if(hour3>=1
------解决方案--------------------
hour3<=-1) {
System.out.println(">=3小时");
}else {
System.out.println("<3小时");
}
}
var date1='2012-01-21 8:2';
var date2='2012-1-2 7:20:10';
var pD=function(s){
var dt=s.split(/ /);
var d=dt[0].split(/-/);
var t;
if(dt[1]){
t=dt[1].split(/:/);
t.push(0);
t.push(0);
}else{
t=[0,0,0];
}
return new Date(d[0],d[1]-1,d[2],t[0],t[1],t[2]);
};
var pS=function(d){
var Y=d.getFullYear();
var M=d.getMonth()+1;
(M<10)&&(M='0'+M);
var D=d.getDate();
(D<10)&&(D='0'+D);