You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (Jira)" <ji...@apache.org> on 2025/01/07 14:07:01 UTC
[jira] [Updated] (BEANUTILS-10) [beanutils] StringLocaleConverter uses same pattern for numbers and dates
[ https://issues.apache.org/jira/browse/BEANUTILS-10?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gary D. Gregory updated BEANUTILS-10:
-------------------------------------
Fix Version/s: 2.0.0-M2
(was: 2.0.0-M1)
> [beanutils] StringLocaleConverter uses same pattern for numbers and dates
> -------------------------------------------------------------------------
>
> Key: BEANUTILS-10
> URL: https://issues.apache.org/jira/browse/BEANUTILS-10
> Project: Commons BeanUtils
> Issue Type: Bug
> Components: Locale BeanUtils / Converters
> Affects Versions: 1.7.0
> Environment: Operating System: All
> Platform: All
> Reporter: Brian Rodgers
> Priority: Major
> Fix For: 2.0.0-M2
>
> Attachments: ASF.LICENSE.NOT.GRANTED--mixed-bean-test.zip
>
>
> StringLocaleConverter doesn't appear to allow for the fact that you need
> separate patterns when converting a date field than you do when converting a
> number field. Hence, when copying values from a typed bean to a String bean
> (such as when copying data into an ActionForm), if the typed bean has both
> numbers and dates, one or the other will be corrupted.
> To reproduce:
> 1. Create a bean that contains a java.util.Date field and a number (any
> numeric object or primative) field.
> 2. Create another bean with matching String fields.
> 3. Populate data into the typed bean from step 1.
> 4. Register a StringLocaleConverter using a date pattern.
> 5. User LocalBeanUtils.copyProperties to copy from the typed bean (step 1) to
> the String bean (step 2).
> 6. Print the fields in the String bean. The date field will be properly
> converted, but the number field will be formatted (to the extent that it can
> be) using the date pattern.
> Of course, it also works the other way -- specify a number pattern and the
> date field will be corrupted.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)