@Test public void testIsSupportedDateFormat() { assertTrue(DateFormat.isSupportedDateFormat("2010-01-01")); assertTrue(DateFormat.isSupportedDateFormat("20100101")); assertTrue(DateFormat.isSupportedDateFormat("2010-01-01 01:01:01")); assertTrue(DateFormat.isSupportedDateFormat("2010-01-01 01:00:00.000")); assertFalse(DateFormat.isSupportedDateFormat("2010-01")); assertFalse(DateFormat.isSupportedDateFormat("2010/01/01")); assertFalse(DateFormat.isSupportedDateFormat("2010-1-1")); assertFalse(DateFormat.isSupportedDateFormat("abc")); }
public static boolean isSupportedDateFormat(String dateStr) { assert dateStr != null; for (String formatStr : SUPPORTED_DATETIME_PATTERN) { try { if (dateStr.equals(dateToString(stringToDate(dateStr, formatStr), formatStr))) { return true; } } catch (Exception ex) { continue; } } return false; }
DateFormat { public static boolean isSupportedDateFormat(String dateStr) { assert dateStr != null; for (String formatStr : SUPPORTED_DATETIME_PATTERN) { try { if (dateStr.equals(dateToString(stringToDate(dateStr, formatStr), formatStr))) { return true; } } catch (Exception ex) { continue; } } return false; } }
DateFormat { public static boolean isSupportedDateFormat(String dateStr) { assert dateStr != null; for (String formatStr : SUPPORTED_DATETIME_PATTERN) { try { if (dateStr.equals(dateToString(stringToDate(dateStr, formatStr), formatStr))) { return true; } } catch (Exception ex) { continue; } } return false; }  }
DateFormat { public static boolean isSupportedDateFormat(String dateStr) { assert dateStr != null; for (String formatStr : SUPPORTED_DATETIME_PATTERN) { try { if (dateStr.equals(dateToString(stringToDate(dateStr, formatStr), formatStr))) { return true; } } catch (Exception ex) { continue; } } return false; }  static FastDateFormat getDateFormat(String datePattern); static String formatToCompactDateStr(long millis); static String formatToDateStr(long millis); static String formatToDateStr(long millis, String pattern); static String formatToTimeStr(long millis); static String formatToTimeWithoutMilliStr(long millis); static String formatToTimeStr(long millis, String pattern); static String dateToString(Date date, String pattern); static Date stringToDate(String str); static Date stringToDate(String str, String pattern); static String formatToTimeStrWithTimeZone(TimeZone timeZone, long mills); static String formatToDateStrWithTimeZone(TimeZone timeZone, long mills); static long stringToMillis(String str); static boolean isSupportedDateFormat(String dateStr); static boolean isInputFormatDate(String dateStr, String formatStr); static boolean isDatePattern(String ptn); }
DateFormat { public static boolean isSupportedDateFormat(String dateStr) { assert dateStr != null; for (String formatStr : SUPPORTED_DATETIME_PATTERN) { try { if (dateStr.equals(dateToString(stringToDate(dateStr, formatStr), formatStr))) { return true; } } catch (Exception ex) { continue; } } return false; }  static FastDateFormat getDateFormat(String datePattern); static String formatToCompactDateStr(long millis); static String formatToDateStr(long millis); static String formatToDateStr(long millis, String pattern); static String formatToTimeStr(long millis); static String formatToTimeWithoutMilliStr(long millis); static String formatToTimeStr(long millis, String pattern); static String dateToString(Date date, String pattern); static Date stringToDate(String str); static Date stringToDate(String str, String pattern); static String formatToTimeStrWithTimeZone(TimeZone timeZone, long mills); static String formatToDateStrWithTimeZone(TimeZone timeZone, long mills); static long stringToMillis(String str); static boolean isSupportedDateFormat(String dateStr); static boolean isInputFormatDate(String dateStr, String formatStr); static boolean isDatePattern(String ptn); static final String COMPACT_DATE_PATTERN; static final String DEFAULT_DATE_PATTERN; static final String DEFAULT_TIME_PATTERN; static final String DEFAULT_DATETIME_PATTERN_WITHOUT_MILLISECONDS; static final String DEFAULT_DATETIME_PATTERN_WITH_MILLISECONDS; static final String DEFAULT_DATETIME_PATTERN_WITH_MILLISECONDS_OFFSET; static final String YYYY_MM_DD_HH_MM; static final String YYYY_MM_DD_HH; static final String YYYYMMDDHHMMSS; static final String YYYYMMDDHHMM; static final String YYYYMMDDHH; static final String ISO_8601_24H_FULL_FORMAT; static final String[] SUPPORTED_DATETIME_PATTERN; }