Uploaded image for project: 'Commons BeanUtils'
  1. Commons BeanUtils
  2. BEANUTILS-385

Integer NumberConverter can't handle strings that contain decimals

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.8.3
    • 2.0.0
    • None

    Description

      We all know that Integers are not supposed to have decimals.

      However, incoming Strings that need to be converted to Integers may not adher to this given. You might get a String such as 120,00 and need to convert that to 120. The pattern matcher for NumberConverter handles string matching. So, if you provide a pattern such as #,##0.00 with a german locale, parsing this String works just fine.
      However, even though the number is successfully parsed, an error is thrown because pos.getIndex() != value.length().

      This may be intentional in order to prevent a decimal 120,50 be converted to something else without warning.

      But what about the other case where you just want the conversion done and precision is irrelevant? Providing a pattern such as #,##0 doesn't work either.

      I mean this is the kind of thing a converter should help you with in stead of block you from

      Attachments

        Activity

          People

            Unassigned Unassigned
            mschipperheyn marc schipperheyn
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: