commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "marc schipperheyn (JIRA)" <>
Subject [jira] Created: (BEANUTILS-385) Integer NumberConverter can't handle strings that contain decimals
Date Wed, 29 Dec 2010 18:21:47 GMT
Integer NumberConverter can't handle strings that contain decimals

                 Key: BEANUTILS-385
             Project: Commons BeanUtils
          Issue Type: Bug
          Components: ConvertUtils & Converters
    Affects Versions: 1.8.3
            Reporter: marc schipperheyn
            Priority: Minor

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

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message