判断当前日期是否在某个日期之前

java判断当前日期是否在某个日期之前:

 /**
     * 判断当前时间是否在某个时间之前
     * @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;
    }

猜你喜欢

转载自blog.csdn.net/duan196_118/article/details/110818578