I carefully studied Jonik 's post on setting up BigDecimal formatting in Wicket. Thanks for the great code. Unfortunately, I cannot get it to work for my use.
I want to register date formatting worldwide and use the following code in a subclass of Application:
@Override protected IConverterLocator newConverterLocator() { ConverterLocator converterLocator = new ConverterLocator(); converterLocator.set(Date.class, new DateConverter() { @Override public DateFormat getDateFormat(Locale ignore) { return new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); } }); return converterLocator; }
Then, when using date fields on web pages, the code looks like this:
form.add(new TextField<Date>("dateField"));
When rendering, the date fields show the standard formatting java.text.DateFormat.SHORT (11/2/11 11:59), coming from the class org.apache.wicket.util.convert.converter.DateConverter instead of my usual SimpleDateFormat (11/02/2011 11:59 : 42).
I checked that java.util.Date is used everywhere. Wicket version 1.4.12.
Any ideas?
source share