public class TimeUtil {
private TimeUtil() {
}
private static final long _1h = 3600000;
public static boolean isToday(long time) {
//Calendar使用单例,多次调用不重复创建对象
Calendar calendar = Calendar.getInstance();
//使用System获取当前时间
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
long today = calendar.getTimeInMillis();
if (time - today < _1h*24&&time-today>0)
return true;
return false;
}
}