@Test public void testGetDateFromStringByFormat() throws ParseException { assertEquals( SAMPLE_DATE, DateDetector.getDateFromStringByFormat( SAMPLE_DATE_STRING, SAMPLE_DATE_FORMAT ) ); try { DateDetector.getDateFromStringByFormat( SAMPLE_DATE_STRING, null ); } catch ( ParseException e ) { } try { DateDetector.getDateFromStringByFormat( null, SAMPLE_DATE_FORMAT ); } catch ( ParseException e ) { } }
public static Date getDateFromStringByFormat( String dateString, String dateFormat ) throws ParseException { if ( dateFormat == null ) { throw new ParseException( "Unknown date format. Format is null. ", 0 ); } if ( dateString == null ) { throw new ParseException( "Unknown date string. Date string is null. ", 0 ); } SimpleDateFormat simpleDateFormat = new SimpleDateFormat( dateFormat ); simpleDateFormat.setLenient( false ); return simpleDateFormat.parse( dateString ); }
DateDetector { public static Date getDateFromStringByFormat( String dateString, String dateFormat ) throws ParseException { if ( dateFormat == null ) { throw new ParseException( "Unknown date format. Format is null. ", 0 ); } if ( dateString == null ) { throw new ParseException( "Unknown date string. Date string is null. ", 0 ); } SimpleDateFormat simpleDateFormat = new SimpleDateFormat( dateFormat ); simpleDateFormat.setLenient( false ); return simpleDateFormat.parse( dateString ); } }
DateDetector { public static Date getDateFromStringByFormat( String dateString, String dateFormat ) throws ParseException { if ( dateFormat == null ) { throw new ParseException( "Unknown date format. Format is null. ", 0 ); } if ( dateString == null ) { throw new ParseException( "Unknown date string. Date string is null. ", 0 ); } SimpleDateFormat simpleDateFormat = new SimpleDateFormat( dateFormat ); simpleDateFormat.setLenient( false ); return simpleDateFormat.parse( dateString ); } private  DateDetector(); }
DateDetector { public static Date getDateFromStringByFormat( String dateString, String dateFormat ) throws ParseException { if ( dateFormat == null ) { throw new ParseException( "Unknown date format. Format is null. ", 0 ); } if ( dateString == null ) { throw new ParseException( "Unknown date string. Date string is null. ", 0 ); } SimpleDateFormat simpleDateFormat = new SimpleDateFormat( dateFormat ); simpleDateFormat.setLenient( false ); return simpleDateFormat.parse( dateString ); } private  DateDetector(); static String getRegexpByDateFormat( String dateFormat ); static String getRegexpByDateFormat( String dateFormat, String locale ); static String getDateFormatByRegex( String regex ); static String getDateFormatByRegex( String regex, String locale ); static Date getDateFromString( String dateString ); static Date getDateFromString( String dateString, String locale ); static Date getDateFromStringByFormat( String dateString, String dateFormat ); static String detectDateFormat( String dateString ); static String detectDateFormat( String dateString, String locale ); static String detectDateFormatBiased( String dateString, String locale, String desiredKey ); static BidiMap getDateFormatToRegExps( String locale ); static boolean isValidDate( String dateString, String dateFormat ); static boolean isValidDate( String dateString ); static boolean isValidDateFormatToStringDate( String dateFormat, String dateString ); static boolean isValidDateFormatToStringDate( String dateFormat, String dateString, String locale ); }
DateDetector { public static Date getDateFromStringByFormat( String dateString, String dateFormat ) throws ParseException { if ( dateFormat == null ) { throw new ParseException( "Unknown date format. Format is null. ", 0 ); } if ( dateString == null ) { throw new ParseException( "Unknown date string. Date string is null. ", 0 ); } SimpleDateFormat simpleDateFormat = new SimpleDateFormat( dateFormat ); simpleDateFormat.setLenient( false ); return simpleDateFormat.parse( dateString ); } private  DateDetector(); static String getRegexpByDateFormat( String dateFormat ); static String getRegexpByDateFormat( String dateFormat, String locale ); static String getDateFormatByRegex( String regex ); static String getDateFormatByRegex( String regex, String locale ); static Date getDateFromString( String dateString ); static Date getDateFromString( String dateString, String locale ); static Date getDateFromStringByFormat( String dateString, String dateFormat ); static String detectDateFormat( String dateString ); static String detectDateFormat( String dateString, String locale ); static String detectDateFormatBiased( String dateString, String locale, String desiredKey ); static BidiMap getDateFormatToRegExps( String locale ); static boolean isValidDate( String dateString, String dateFormat ); static boolean isValidDate( String dateString ); static boolean isValidDateFormatToStringDate( String dateFormat, String dateString ); static boolean isValidDateFormatToStringDate( String dateFormat, String dateString, String locale );  }