【java判断当前时间是否大于某个时间】
/*** 判断当前时间是否大于某个时间* @param time yyyy-MM-dd HH:mm:ss* @return*/public static boolean dateCompare(String time){SimpleDateFormat sdf=new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”);try {long start = sdf.par
·
/**
* 判断当前时间是否大于某个时间
* @param time yyyy-MM-dd HH:mm:ss
* @return
*/
public static boolean dateCompare(String time){
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
long start = sdf.parse(time).getTime();
//获取当前时间毫秒值
long current = System.currentTimeMillis();// 返回一个毫秒数
//判断当前时间大于21分钟
if((current - start)/ 1000 / 60 > 21){
//System.out.println("大于21min---------------");
return true;
}
//System.out.println("小于21min----------------");
} catch (ParseException e) {
e.printStackTrace();
}
return false;
}
更多推荐
所有评论(0)