当前位置: 代码迷 >> Java相关 >> 关于时间的判断解决方法
  详细解决方案

关于时间的判断解决方法

热度:6150   发布时间:2013-02-25 21:42:14.0
关于时间的判断
我需要判断当前的时间是不是在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
  相关解决方案