Results 1 to 2 of 2

Thread: Custom Editors for Date and Double objects

  1. #1
    Join Date
    Aug 2004
    Location
    Southern Germany
    Posts
    30

    Default Custom Editors for Date and Double objects

    I have problems with converting/formatting java.util.Date and java.lang.Double objects.

    Date objects don't get the right format when loading. I've registered a CustomDateEditor with

    SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
    binder.registerCustomEditor(Date.class, null, new CustomDateEditor(dateFormat, true));

    When loading the form, the field value shows up as "yyyy-MM-dd".

    The second problem is with Double objects registered like

    binder.registerCustomEditor(Double.class, null, new CustomNumberEditor(Double.class, nf, true));

    When submitting a value like "98.99" in the form, Spring saves "9899".

    After reloading the value looks like "9899.0".

    How can I use these two object types in Spring ?
    Regards,
    Lars Fischer
    http://j2ux.blogspot.com

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    If your Locale is German, I think your default numbers have a comma instead of a dot to indicate the decimal place (e.g. 98.99 will give 9899.0) - try entering 98,99. Look at changing the Locale or java.text.DecimalFormatSymbols to change this.

    With the date, can you provide more information. I'm not sure why this would occur.

Similar Threads

  1. Replies: 1
    Last Post: Oct 25th, 2005, 09:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •