计算时间差值
时间比较大小
public class Test {
public static void main(String[] args) {
String str="2016-09-10 11:49:19.0";
System.out.println(compareTime(str));
}
public static boolean compareTime(String str){
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
Date date=sdf.parse(str);
Long old=date.getTime();
Long current=System.currentTimeMillis();
long time=24*60*60*1000L;
old=old+time;
if(old>=current){
return true;
}
} catch (ParseException e) {
e.printStackTrace();
}
return false;
}
}