Wicket
  1. Wicket
  2. WICKET-1395

BigDecimalConverter does not work with space - eg, French or Russian Locales.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3.1
    • Fix Version/s: 1.3.2
    • Component/s: wicket
    • Labels:
      None

      Description

      Space character is not getting correctly translated when converting to BigDecimal.

      The following occurs with a bound BigDecimal field

      Input: 3000
      Submit
      Output: 3 000


      Input: 3 000
      Submit
      Output: 3

      The following code highlights the problem.

      BigDecimalConverter bdc = new BigDecimalConverter();
      System.out.println(bdc.convertToObject("3 000", Locale.FRENCH));
      =>3

      DoubleConverter dc = new DoubleConverter();
      System.out.println(dc.convertToObject("3 000", Locale.FRENCH));
      =>3000.0

      I think I found the problem.

      BigDecimalConverter#convertToObject is calling getNumberFormat(locale), but it should be calling AbstractNumberConverter#parse like DoubleConverter does (or something similar).

      It looks like code to handle the different "thousand" separators has been added there.

      Also of note, it does not appear that the BigDecimalConverter is covered by the Converters test.

      See thread http://www.nabble.com/BigDecimal-converter---broken-for-French-Russian-%21--ts15820747.html for more context.

        Activity

        Hide
        Johan Compagner added a comment -

        fixed it by doing the same stuff as the double converter

        Show
        Johan Compagner added a comment - fixed it by doing the same stuff as the double converter

          People

          • Assignee:
            Johan Compagner
            Reporter:
            Ned Collyer
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development