@Test(groups = "fast") public void testUkLocaleDates() { Collection<ValidationError> errors = new ArrayList<ValidationError>(); DateTypeConverter converter = getConverter(Locale.UK); Date date = converter.convert("31 01 2007", Date.class, errors); Assert.assertNotNull(date); Assert.assertEquals(0, errors.size()); Assert.assertEquals(format.format(date), "01/31/2007"); date = converter.convert("28/02/2006", Date.class, errors); Assert.assertNotNull(date); Assert.assertEquals(0, errors.size()); Assert.assertEquals(format.format(date), "02/28/2006"); date = converter.convert("01 March 2007", Date.class, errors); Assert.assertNotNull(date); Assert.assertEquals(0, errors.size()); Assert.assertEquals(format.format(date), "03/01/2007"); }
public Date convert(String input, Class<? extends Date> targetType, Collection<ValidationError> errors) { String parseable = preProcessInput(input); Date date = null; for (DateFormat format : this.formats) { try { date = format.parse(parseable); break; } catch (ParseException pe) { } } if (date != null) { return date; } else { errors.add(new ScopedLocalizableError("converter.date", "invalidDate")); return null; } }
DateTypeConverter implements TypeConverter<Date> { public Date convert(String input, Class<? extends Date> targetType, Collection<ValidationError> errors) { String parseable = preProcessInput(input); Date date = null; for (DateFormat format : this.formats) { try { date = format.parse(parseable); break; } catch (ParseException pe) { } } if (date != null) { return date; } else { errors.add(new ScopedLocalizableError("converter.date", "invalidDate")); return null; } } }
DateTypeConverter implements TypeConverter<Date> { public Date convert(String input, Class<? extends Date> targetType, Collection<ValidationError> errors) { String parseable = preProcessInput(input); Date date = null; for (DateFormat format : this.formats) { try { date = format.parse(parseable); break; } catch (ParseException pe) { } } if (date != null) { return date; } else { errors.add(new ScopedLocalizableError("converter.date", "invalidDate")); return null; } }  }
DateTypeConverter implements TypeConverter<Date> { public Date convert(String input, Class<? extends Date> targetType, Collection<ValidationError> errors) { String parseable = preProcessInput(input); Date date = null; for (DateFormat format : this.formats) { try { date = format.parse(parseable); break; } catch (ParseException pe) { } } if (date != null) { return date; } else { errors.add(new ScopedLocalizableError("converter.date", "invalidDate")); return null; } }  void setLocale(Locale locale); Locale getLocale(); Date convert(String input,
            Class<? extends Date> targetType,
            Collection<ValidationError> errors); }
DateTypeConverter implements TypeConverter<Date> { public Date convert(String input, Class<? extends Date> targetType, Collection<ValidationError> errors) { String parseable = preProcessInput(input); Date date = null; for (DateFormat format : this.formats) { try { date = format.parse(parseable); break; } catch (ParseException pe) { } } if (date != null) { return date; } else { errors.add(new ScopedLocalizableError("converter.date", "invalidDate")); return null; } }  void setLocale(Locale locale); Locale getLocale(); Date convert(String input,
            Class<? extends Date> targetType,
            Collection<ValidationError> errors); static final Pattern PRE_PROCESS_PATTERN; static final String[] formatStrings; static final String KEY_FORMAT_STRINGS; static final String KEY_PRE_PROCESS_PATTERN; }