I need to replace the default Wicket Date conversion with a custom one to
override the default format for dates.

To do that I've made something like that in my wicket application :


 getApplicationSettings().setConverterFactory( new IConverterFactory() {
   public IConverter newConverter(Locale locale) {
               return new MyConverter() ;
           } }  );


Where:


public class MyConverter extends Converter {

   public MyConverter() {
       super();
       set(Date.class, new MyDateConverter());
       set(String.class, new MyStringConverter() );
   }

   public MyConverter(final Locale locale)
   {
       this();
       setLocale(locale);
   }

}

public class MyDateConverter extends AbstractConverter {

   protected Class getTargetType()
   {
       return Date.class;
   }

   public Object convert(final Object value, Locale locale)
   {
       return parse(MY_DATE_FORMAT, value);
   }
}

public class MyStringConverter extends AbstractConverter { ....
 /*
  * ... that requires also an extra class MyDateToStringConverter ..
  */
}


This is really too complex to do a trivial job like a Date <---> String
conversion .

Exists a better and simpler way to override the default date-string
conversion ?

Thank you,

Paolo Di Tommaso
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to