valid date

 

	public final static boolean isValidDate(final String date, final String format) {

		boolean result = false;
		try{
			Date d = toDate(date, format);
			String s = DateFormatUtil.format(d, format);
			result = s.equals(date);
		} catch (Exception ex) {
		}
		return result;
	}

	public final static boolean isValidDate(final String date, final String format) {
		boolean result = false;
		try{
			Date d = toDate(date, format);
			String s = DateFormatUtil.format(d, format);
			result = s.equals(date);
		} catch (Exception ex) {
		}
		return result;
	}

 

invalid date: 20170230,20170232

 

 

 if(!DateUtil.isValidDate(dateString, SDConstant.DK_ASSESSMENT_INFO_IMPORT_DKREVIEW_DATE_FORMAT)){
    throw new AppException(ErrorCodeConstant.DK_ASSESSMENT_IMPORT_DATE_PARSING_ERROR, new String[]{dateString, String.valueOf(dataSet.getRowNo())},null);
}

 

 

你可能感兴趣的:(java)