这是我的活动时间:
java.util.GregorianCalendar中[时间= 1454970600000,areFieldsSet =真,宽大=真,区=亚/加尔各答,Firstdayofweek可= 2,minimalDaysInFirstWeek = 4,ERA = 1,YEAR = 2016,月= 1,WEEK_OF_YEAR = 6 ,WEEK_OF_MONTH = 2,DAY_OF_MONTH = 9,DAY_OF_YEAR = 40,DAY_OF_WEEK = 3,DAY_OF_WEEK_IN_MONTH = 2,AM_PM = 0,HOUR = 4,HOUR_OF_DAY = 4,MINUTE = 0,SECOND = 0,微差= 0,ZONE_OFFSET = 19800000,DST_OFFSET = 0]
我将活动时间设置为:
Calendar startTime = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String date = data.get(i).getSchdDate();
String hour = data.get(i).getFromTime();
try {
startTime.setTime(sdf.parse(date + " " + hour));
} catch (ParseException e) {
e.printStackTrace();
}
现在我想知道这个时间是否小于当前时间?如何实现?
答案 0 :(得分:3)
如果该日历位于名为cal的变量中:
if (cal.getTimeInMillis() < System.currentTimeMillis()) {
// do what you want
}