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

[beanutils] StringLocaleConverter uses same pattern for numbers and dates

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.7.0
    • 2.0.0
    • None
    • Operating System: All
      Platform: All

    • 39477

    Description

      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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            bkrodgers@bigfoot.com Brian Rodgers
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: