### Question:
CalendarConverterFactory implements TypeConverterFactory<String, Calendar> { @Override public TypeConverter<String, Calendar> createTypeConverter() { return new StringToDateLocaleAwareConverter<Calendar>() { @Override protected Calendar doConvert(Date date) { final Calendar calendar = Calendar.getInstance(getLocale()); calendar.setTime(date); calendar.setTimeZone(TimeZone.getTimeZone(zoneId)); return calendar; } }; }  @Override TypeConverter<String, Calendar> createTypeConverter(); @Override TypeConverterDescriptor<Class<String>, Class<Calendar>> getTypeConverterDescriptor();  }### Answer:
@Test public void test_CalendarDecoder() { Properties config = new Properties(); config.setProperty(DateLocaleAwareTypeConverter.FORMAT, "EEE MMM dd HH:mm:ss z yyyy"); CalendarConverterFactory calendarConverterFactory = new CalendarConverterFactory(); config.setProperty(DateLocaleAwareTypeConverter.LOCALE_LANGUAGE_CODE, "en"); config.setProperty(DateLocaleAwareTypeConverter.LOCALE_COUNTRY_CODE, "IE"); config.setProperty(DateLocaleAwareTypeConverter.ZONE_ID, "America/New_York"); TypeConverter<String, Calendar> typeConverter = calendarConverterFactory.createTypeConverter(); ((Configurable) typeConverter).setConfiguration(config); Calendar cal_a = typeConverter.convert("Wed Nov 15 13:45:28 EST 2006"); assertEquals(1163616328000L, cal_a.getTimeInMillis()); assertEquals("Eastern Standard Time", cal_a.getTimeZone().getDisplayName( new Locale("en", "IE") ) ); Calendar cal_b = typeConverter.convert("Wed Nov 15 13:45:28 EST 2006"); assertNotSame(cal_a, cal_b); }
@Test public void test_CalendarDecoder_with_swedish_local() throws ParseException { final String dateFormat = "EEE MMM dd HH:mm:ss z yyyy"; final String dateString = "ti mar 04 15:25:07 CET 2008"; Properties config = new Properties(); CalendarConverterFactory calendarConverterFactory = new CalendarConverterFactory(); config.setProperty(DateLocaleAwareTypeConverter.FORMAT, dateFormat ); config.setProperty(DateLocaleAwareTypeConverter.LOCALE_LANGUAGE_CODE, "sv"); config.setProperty(DateLocaleAwareTypeConverter.LOCALE_COUNTRY_CODE, "SE"); config.setProperty(DateLocaleAwareTypeConverter.VERIFY_LOCALE, "true"); TypeConverter<String, Calendar> typeConverter = calendarConverterFactory.createTypeConverter(); ((Configurable) typeConverter).setConfiguration(config); Calendar cal_a = typeConverter.convert(dateString); assertEquals("Centraleuropeisk tid", cal_a.getTimeZone().getDisplayName( new Locale("sv", "SE") ) ); Calendar cal_b = typeConverter.convert(dateString); assertNotSame(cal_a, cal_b); }