时间操作(一)

public static boolean dateCompare(String dateStr)
	{
		Calendar calendar = Calendar.getInstance();
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat(TimeFormatPattern.DEFAULT);
		Date date = null;
		try
		{
			date = simpleDateFormat.parse(dateStr);
		} catch (ParseException e)
		{
			LOGGER.error("日期格式化错误"+e.getMessage());
		}
		calendar.setTime(date);
		calendar.add(Calendar.DATE, 1);
		if(!calendar.after(new Date())){
			LOGGER.info("日期没有超过当前时间一天,无法进行下面的操作");
			return false;
		}
		return true;
	}

你可能感兴趣的:(java)