/** * @see org.apache.wicket.markup.html.form.AbstractTextComponent.ITextFormatProvider#getTextFormat() */ @Override public final String getTextFormat() { return converter.getDatePattern(getLocale()); } }
/** * @see org.apache.wicket.util.convert.IConverter#convertToString(java.lang.Object, * java.util.Locale) */ @Override public String convertToString(Date value, Locale locale) { DateTime dt = new DateTime(value.getTime(), getTimeZone()); DateTimeFormatter format = getFormat(locale); if (applyTimeZoneDifference) { TimeZone zone = getClientTimeZone(); if (zone != null) { // apply time zone to formatter format = format.withZone(DateTimeZone.forTimeZone(zone)); } } return format.print(dt); }
DateTimeFormatter format = getFormat(locale); if (format == null) TimeZone zone = getClientTimeZone(); DateTime dateTime; format = format.withZone(getTimeZone()); throw newConversionException(e, locale); throw newConversionException(e, locale);
DateTimeFormatter format = getFormat(locale); if (format == null) TimeZone zone = getClientTimeZone(); DateTime dateTime; format = format.withZone(getTimeZone()); throw newConversionException(e, locale); throw newConversionException(e, locale);
/** * @see org.apache.wicket.util.convert.IConverter#convertToString(java.lang.Object, * java.util.Locale) */ @Override public String convertToString(Date value, Locale locale) { DateTime dt = new DateTime(value.getTime(), getTimeZone()); DateTimeFormatter format = getFormat(locale); if (applyTimeZoneDifference) { TimeZone zone = getClientTimeZone(); if (zone != null) { // apply time zone to formatter format = format.withZone(DateTimeZone.forTimeZone(zone)); } } return format.print(dt); }
/** * @see org.apache.wicket.markup.html.form.AbstractTextComponent.ITextFormatProvider#getTextFormat() */ @Override public final String getTextFormat() { return converter.getDatePattern(getLocale()); } }
/** * Creates a ConversionException and sets additional context information to it. * * @param cause * - {@link RuntimeException} cause * @param locale * - {@link Locale} used to set 'format' variable with localized pattern * @return {@link ConversionException} */ private ConversionException newConversionException(RuntimeException cause, Locale locale) { return new ConversionException(cause) .setVariable("format", getDatePattern(locale)); }
/** * Creates a ConversionException and sets additional context information to it. * * @param cause * - {@link RuntimeException} cause * @param locale * - {@link Locale} used to set 'format' variable with localized pattern * @return {@link ConversionException} */ private ConversionException newConversionException(RuntimeException cause, Locale locale) { return new ConversionException(cause) .setVariable("format", getDatePattern(locale)); }
/** * Gets the date pattern to use for putting selected values in the coupled component. * * @return The date pattern */ protected String getDatePattern() { String format = null; if (component instanceof ITextFormatProvider) { format = ((ITextFormatProvider) component).getTextFormat(); // it is possible that components implement ITextFormatProvider but // don't provide a format } if (format == null) { IConverter converter = component.getConverter(DateTime.class); if (!(converter instanceof DateConverter)) { converter = component.getConverter(Date.class); } format = ((DateConverter) converter).getDatePattern(component.getLocale()); } return format; }