public static boolean checkDate(String str) {
boolean bolRet = true;
if (StringUtils.isNotEmpty(str)) {
try {
SimpleDateFormat formatDate = new SimpleDateFormat("yyyy/MM/dd");
// 将某个日期以固定格式转化成字符串
// String str
= sdf.format(formatDate );
formatDate.setLenient(false);
Calendar calendar = Calendar.getInstance();
java.util.Date date = formatDate.parse(str);
calendar.setTime(date);
int nowYear = calendar.get(Calendar.YEAR);
bolRet = (nowYear >= 2000) && (nowYear <= 9999)
&& formatDate.format(date).equals(str);
} catch (Exception ex) {
bolRet = false;
System.out.println(ex);
}
}
return bolRet;
}
posted on 2008-05-23 15:53
scea2009 阅读(167)
评论(0) 编辑 收藏