日期:2014-05-20  浏览次数:20661 次

关于时间的判断
我需要判断当前的时间是不是在8:00到10:30之间 然后返回一个boolean的值 因为每天都需要进行判断 所以只要在小时分钟之间就行  代码尽量简化 方法尽量简单

------解决方案--------------------

private static boolean checkTime() {
SimpleDateFormat sdf = new SimpleDateFormat("HHmm");
int hm = Integer.valueOf(sdf.format(new Date()));
if (hm >= 800 && hm <= 1030) {
return true;
}
return false;
}

------解决方案--------------------
引用:
Java code
private static boolean checkTime() {     SimpleDateFormat sdf = new SimpleDateFormat("HHmm");     int hm = Integer.valueOf(sdf.format(new Date()));     if (hm >= 800 &……

+1