- /**
- * 判断时间格式 格式必须为“YYYY-MM-dd”
- * 2004-2-30 是无效的
- * 2003-2-29 是无效的
- * @param sDate
- * @return
- */
- private static boolean isLegalDate(String sDate) {
- int legalLen = 10;
- if ((sDate == null) || (sDate.length() != legalLen)) {
- return false;
- }
-
- DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
- try {
- Date date = formatter.parse(sDate);
- return sDate.equals(formatter.format(date));
- } catch (Exception e) {
- return false;
- }
- }