@Test public void convertToObject() { final TimeZoneConverter con = new TimeZoneConverter(); final Locale locale = Locale.ENGLISH; assertNull(con.convertToObject(null, locale)); assertNull(con.convertToObject("", locale)); assertEquals("Europe/Berlin", ((TimeZone) con.convertToObject("Europe/Berlin", locale)).getID()); assertEquals("CET", ((TimeZone) con.convertToObject("CET", locale)).getID()); }
@Override public Object convertToObject(final String value, final Locale locale) { if (StringUtils.isEmpty(value) == true) { return null; } final int ind = value.indexOf(" ("); final String id = ind >= 0 ? value.substring(0, ind) : value; final TimeZone timeZone = TimeZone.getTimeZone(id); if (timeZone.getID().toLowerCase(locale).equals(id.toLowerCase(locale)) == false) { error(); return null; } return timeZone; }
TimeZoneConverter implements IConverter { @Override public Object convertToObject(final String value, final Locale locale) { if (StringUtils.isEmpty(value) == true) { return null; } final int ind = value.indexOf(" ("); final String id = ind >= 0 ? value.substring(0, ind) : value; final TimeZone timeZone = TimeZone.getTimeZone(id); if (timeZone.getID().toLowerCase(locale).equals(id.toLowerCase(locale)) == false) { error(); return null; } return timeZone; } }
TimeZoneConverter implements IConverter { @Override public Object convertToObject(final String value, final Locale locale) { if (StringUtils.isEmpty(value) == true) { return null; } final int ind = value.indexOf(" ("); final String id = ind >= 0 ? value.substring(0, ind) : value; final TimeZone timeZone = TimeZone.getTimeZone(id); if (timeZone.getID().toLowerCase(locale).equals(id.toLowerCase(locale)) == false) { error(); return null; } return timeZone; }  }
TimeZoneConverter implements IConverter { @Override public Object convertToObject(final String value, final Locale locale) { if (StringUtils.isEmpty(value) == true) { return null; } final int ind = value.indexOf(" ("); final String id = ind >= 0 ? value.substring(0, ind) : value; final TimeZone timeZone = TimeZone.getTimeZone(id); if (timeZone.getID().toLowerCase(locale).equals(id.toLowerCase(locale)) == false) { error(); return null; } return timeZone; }  @Override Object convertToObject(final String value, final Locale locale); @Override String convertToString(final Object value, final Locale locale); }
TimeZoneConverter implements IConverter { @Override public Object convertToObject(final String value, final Locale locale) { if (StringUtils.isEmpty(value) == true) { return null; } final int ind = value.indexOf(" ("); final String id = ind >= 0 ? value.substring(0, ind) : value; final TimeZone timeZone = TimeZone.getTimeZone(id); if (timeZone.getID().toLowerCase(locale).equals(id.toLowerCase(locale)) == false) { error(); return null; } return timeZone; }  @Override Object convertToObject(final String value, final Locale locale); @Override String convertToString(final Object value, final Locale locale);  }