commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niall Pemberton (JIRA)" <j...@apache.org>
Subject [jira] Commented: (BEANUTILS-385) Integer NumberConverter can't handle strings that contain decimals
Date Thu, 30 Dec 2010 21:45:46 GMT

    [ https://issues.apache.org/jira/browse/BEANUTILS-385?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12976118#action_12976118
] 

Niall Pemberton commented on BEANUTILS-385:
-------------------------------------------

You can create and register your own integer converter that parses decimals - except pass
"true" to the super constructor to parse decimals

http://svn.apache.org/repos/asf/commons/proper/beanutils/trunk/src/main/java/org/apache/commons/beanutils/converters/IntegerConverter.java

> Integer NumberConverter can't handle strings that contain decimals
> ------------------------------------------------------------------
>
>                 Key: BEANUTILS-385
>                 URL: https://issues.apache.org/jira/browse/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 from

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


Mime
View raw message