/** * @see org.apache.wicket.markup.html.form.AbstractTextComponent.ITextFormatProvider#getTextFormat() */ @Override public final String getTextFormat() { return converter.getDatePattern(getLocale()); } }
/** * Creates a new DateLabel defaulting to using a short date pattern * * @param id * The id of the text field * @param model * The model * @return new instance * * @see org.apache.wicket.markup.html.form.TextField */ public static DateLabel forShortStyle(String id, IModel<Date> model) { return new DateLabel(id, model, new StyleDateConverter(true)); }
/** * Creates a new DateTextField defaulting to using a short date pattern * * @param id * The id of the text field * @param model * The model * @param applyTimeZoneDifference * Whether to apply the time zone difference between client and server * @return DateTextField */ public static DateTextField forShortStyle(String id, IModel<Date> model, boolean applyTimeZoneDifference) { return new DateTextField(id, model, new StyleDateConverter(applyTimeZoneDifference)); }
DateTextField txtInvoiceDate=new DateTextField("txtInvoiceDate",new PropertyModel<Date>(objmodel, "txtInvoiceDate"),new PatternDateConverter("dd/MM/yyyy", true)); DatePicker picker = new DatePicker(){ @Override protected boolean enableMonthYearSelection() { return true; } }; txtInvoiceDate.add(new DatePicker()); add(txtInvoiceDate);
/** * Creates a new DateTextField defaulting to using a short date pattern * * @param id * The id of the text field * @param model * The model * @param datePattern * The pattern to use. Must be not null. See {@link SimpleDateFormat} for available * patterns. * @return DateTextField */ public static DateTextField forDatePattern(String id, IModel<Date> model, String datePattern) { return new DateTextField(id, model, new PatternDateConverter(datePattern, true)); }
/** * Creates a new DateLabel defaulting to using a short date pattern * * @param id * The id of the text field * @param model * The model * @param datePattern * The pattern to use. Must be not null. See {@link SimpleDateFormat} for available * patterns. * @return new instance * * @see org.apache.wicket.markup.html.form.TextField */ public static DateLabel forDatePattern(String id, IModel<Date> model, String datePattern) { return new DateLabel(id, model, new PatternDateConverter(datePattern, true)); }
/** * 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)); }
/** * @return formatter The formatter for the current conversion */ @Override protected DateTimeFormatter getFormat(Locale locale) { return DateTimeFormat.forPattern(getDatePattern(locale)) .withLocale(locale) .withPivotYear(2000); } }
/** * Creates a new DateTextField defaulting to using a short date pattern * * @param id * The id of the text field * @param model * The model * @param applyTimeZoneDifference * Whether to apply the time zone difference between client and server * @return DateTextField */ public static DateTextField forShortStyle(String id, IModel<Date> model, boolean applyTimeZoneDifference) { return new DateTextField(id, model, new StyleDateConverter(applyTimeZoneDifference)); }
/** * Creates a new DateLabel defaulting to using a short date pattern * * @param id * The id of the text field * @param model * The model * @return new instance * * @see org.apache.wicket.markup.html.form.TextField */ public static DateLabel forShortStyle(String id, IModel<Date> model) { return new DateLabel(id, model, new StyleDateConverter(true)); }
/** * Creates a new DateTextField defaulting to using a short date pattern * * @param id * The id of the text field * @param model * The model * @param datePattern * The pattern to use. Must be not null. See {@link SimpleDateFormat} for available * patterns. * @return DateTextField */ public static DateTextField forDatePattern(String id, IModel<Date> model, String datePattern) { return new DateTextField(id, model, new PatternDateConverter(datePattern, true)); }
/** * Creates a new DateLabel defaulting to using a short date pattern * * @param id * The id of the text field * @param model * The model * @param datePattern * The pattern to use. Must be not null. See {@link SimpleDateFormat} for available * patterns. * @return new instance * * @see org.apache.wicket.markup.html.form.TextField */ public static DateLabel forDatePattern(String id, IModel<Date> model, String datePattern) { return new DateLabel(id, model, new PatternDateConverter(datePattern, true)); }
/** * @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)); }
/** * @return formatter The formatter for the current conversion */ @Override protected DateTimeFormatter getFormat(Locale locale) { return DateTimeFormat.forPattern(getDatePattern(locale)) .withLocale(locale) .withPivotYear(2000); } }
/** * Creates a new DateTextField using the provided date style. * * @param id * The id of the text field * @param model * The model * @param dateStyle * Date style to use. The first character is the date style, and the second character * is the time style. Specify a character of 'S' for short style, 'M' for medium, 'L' * for long, and 'F' for full. A date or time may be ommitted by specifying a style * character '-'. See {@link DateTimeFormat#forStyle(String)}. * @return DateTextField */ public static DateTextField forDateStyle(String id, IModel<Date> model, String dateStyle) { return new DateTextField(id, model, new StyleDateConverter(dateStyle, true)); }
/** * Creates a new DateLabel defaulting to using a short date pattern * * @param id * The id of the text field * @param model * The model * @param dateStyle * style to use in case no pattern is provided. Must be two characters from the set * {"S", "M", "L", "F", "-"}. Must be not null. See * {@link DateTimeFormat#forStyle(String)} for options. * @return new instance * * @see org.apache.wicket.markup.html.form.TextField */ public static DateLabel forDateStyle(String id, IModel<Date> model, String dateStyle) { return new DateLabel(id, model, new StyleDateConverter(dateStyle, true)); }
/** * 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; }
/** * Creates a new DateTextField using the provided date style. * * @param id * The id of the text field * @param model * The model * @param dateStyle * Date style to use. The first character is the date style, and the second character * is the time style. Specify a character of 'S' for short style, 'M' for medium, 'L' * for long, and 'F' for full. A date or time may be ommitted by specifying a style * character '-'. See {@link DateTimeFormat#forStyle(String)}. * @return DateTextField */ public static DateTextField forDateStyle(String id, IModel<Date> model, String dateStyle) { return new DateTextField(id, model, new StyleDateConverter(dateStyle, true)); }
/** * Creates a new DateLabel defaulting to using a short date pattern * * @param id * The id of the text field * @param model * The model * @param dateStyle * style to use in case no pattern is provided. Must be two characters from the set * {"S", "M", "L", "F", "-"}. Must be not null. See * {@link DateTimeFormat#forStyle(String)} for options. * @return new instance * * @see org.apache.wicket.markup.html.form.TextField */ public static DateLabel forDateStyle(String id, IModel<Date> model, String dateStyle) { return new DateLabel(id, model, new StyleDateConverter(dateStyle, true)); }