网上找了几个版本 都不是很清晰,想具体到时分秒改日期格式即可
/**
* 判断当前时间是否在某个时间之前
*
* @param tagDateTime 判断的标准
* @return true是,false不是
*/
public static boolean belongCalendarBefore(String tagDateTime) {
try {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Calendar contCalendar = Calendar.getInstance();
Calendar tagCalendar = (Calendar) contCalendar.clone();
tagCalendar.setTime(dateFormat.parse(tagDateTime));
return contCalendar.before(tagCalendar);
} catch (ParseException e) {
e.printStackTrace();
}
return false;
}
本文介绍了一个实用的Java方法,用于判断当前时间是否在指定的日期时间之前。通过使用SimpleDateFormat和Calendar类,该方法能够准确地进行时间比较。

1148

被折叠的 条评论
为什么被折叠?



