java获取前一天时间SimpleDateFormat
SimpleDateFormat predf = new SimpleDateFormat("yyyy-MM-dd"); Date d=new Date(); String predate = predf.format(new Date(d.getTime() - (long)24 * 60 * 60 * 1000));
java判断某个时间段
SimpleDateFormat dfh = new SimpleDateFormat("HH"); String h = dfh.format(new Date()); if (Integer.parseInt(h) > 2 && Integer.parseInt(h) < 10) { System.out.println("时间10:00-2:00未到"); }