Compare GregorianCalendar time with current time
this is My Events time:
java.util.GregorianCalendar[time=1454970600000,areFieldsSet=true,lenient=true,zone=Asia/Calcutta,firstDayOfWeek=2,minimalDaysInFirstWeek=4,ERA=1,YEAR=2016,MONTH=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,MILLISECOND=0,ZONE_OFFSET=19800000,DST_OFFSET=0]
i am setting my event time as:
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();
}
and now i want to know if this time is smaller than the current time or not? How to achieve that?
如果该日历位于名为cal的变量中:
if (cal.getTimeInMillis() < System.currentTimeMillis()) {
// do what you want
}
链接地址: http://www.djcxy.com/p/18704.html
上一篇: 三星J7返回第一天为2