@Test public void convertToString() { contextUser.setTimeZone(DateHelper.EUROPE_BERLIN); contextUser.setLocale(Locale.GERMAN); contextUser.setDateFormat("dd.MM.yyyy"); JodaDateConverter conv = new JodaDateConverter(); DateMidnight testDate = createDate(1970, DateTimeConstants.NOVEMBER, 21, EUROPE_BERLIN); assertEquals("21.11.1970", conv.convertToString(testDate, Locale.GERMAN)); contextUser.setLocale(Locale.ENGLISH); contextUser.setDateFormat("MM/dd/yyyy"); conv = new JodaDateConverter(); assertEquals("11/21/1970", conv.convertToString(testDate, Locale.GERMAN)); contextUser.setLocale(Locale.GERMAN); contextUser.setDateFormat("dd.MM.yyyy"); conv = new JodaDateConverter(); testDate = createDate(2009, DateTimeConstants.FEBRUARY, 1, EUROPE_BERLIN); assertEquals("01.02.2009", conv.convertToString(testDate, Locale.GERMAN)); contextUser.setLocale(Locale.ENGLISH); contextUser.setDateFormat("MM/dd/yyyy"); conv = new JodaDateConverter(); assertEquals("02/01/2009", conv.convertToString(testDate, Locale.GERMAN)); }
@Override public String convertToString(final DateMidnight value, final Locale locale) { if (value == null) { return null; } final DateTimeFormatter formatter = getDateTimeFormatter(userDateFormat, locale); return formatter.print(value); }
JodaDateConverter implements IConverter<DateMidnight> { @Override public String convertToString(final DateMidnight value, final Locale locale) { if (value == null) { return null; } final DateTimeFormatter formatter = getDateTimeFormatter(userDateFormat, locale); return formatter.print(value); } }
JodaDateConverter implements IConverter<DateMidnight> { @Override public String convertToString(final DateMidnight value, final Locale locale) { if (value == null) { return null; } final DateTimeFormatter formatter = getDateTimeFormatter(userDateFormat, locale); return formatter.print(value); } JodaDateConverter(); }
JodaDateConverter implements IConverter<DateMidnight> { @Override public String convertToString(final DateMidnight value, final Locale locale) { if (value == null) { return null; } final DateTimeFormatter formatter = getDateTimeFormatter(userDateFormat, locale); return formatter.print(value); } JodaDateConverter(); String getPattern(); @Override String convertToString(final DateMidnight value, final Locale locale); @Override DateMidnight convertToObject(final String value, final Locale locale); }
JodaDateConverter implements IConverter<DateMidnight> { @Override public String convertToString(final DateMidnight value, final Locale locale) { if (value == null) { return null; } final DateTimeFormatter formatter = getDateTimeFormatter(userDateFormat, locale); return formatter.print(value); } JodaDateConverter(); String getPattern(); @Override String convertToString(final DateMidnight value, final Locale locale); @Override DateMidnight convertToObject(final String value, final Locale locale); static final int PIVOT_YEAR; }