Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None
    • Environment:

      Operating System: other
      Platform: Other

    • Bugzilla Id:
      30272

      Description

      actually, ConvertUtils from BeanUtils is used like this in the
      BasicTypeConverter:

      if (ConvertUtils.lookup(toType) != null) {
      return ConvertUtils.convert(object.toString(), toType);
      }

      the toString() could cause some problem: imagine that my property is a Date and
      I would like it to be converted to an Integer like this:

      context.getValue("record/lastModificationDate", Integer.class);

      The toString() will get me something like 'November Wed 17h, 2002' then will
      try to convert this to a number which is kinda problematic because it is now a
      string and you've lost the fact that it was a date before (which is required to
      know how to convert it).

      I propose to skip the toString() by directly using the looked up Converter
      which can take an object as argument instead of a string:

      Converter converter = ConvertUtils.lookup(toType);
      if (converter != null) {
      return converter.convert(toType, object);
      }

      By the way, did you take a look at the Convert component in the commons sandbox?

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              xdury@hotmail.com Xavier Dury
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: