我想测试转换为日历的字符串是现在之前还是之后。我不明白为什么这不起作用:
public final static SimpleDateFormat DATE_FORMAT_RESERVATION_HOUR = new SimpleDateFormat("HH:mm");
String str = "14:00";
Calendar now = Calendar.getInstance();
Calendar selected = Calendar.getInstance();
//avoiding try/catch in this post
selected.set(Calendar.HOUR_OF_DAY, (int) DATE_FORMAT_RESERVATION_HOUR.parse(str).getTime());
// selected = now : 7352-05-18 00:49:33 (instead of 2013-06-17 14:00:00
Log.d("test", "after?" + selected.after(now));
我希望现在是“选定”,但在 str 中指定了小时。欢迎任何帮助!谢谢