XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Nightly Builds
    • None
    • Convert
    • None

    Description

      FloatToString seems to return unexpected results.

      Test Case:
      @Test
      public void testFloatFormat() throws Exception

      { Float testFloat = new Float(100.1878783420); FloatToString fts = new FloatToString(); String format = "###.##"; String v1 = fts.convert(new Float(100.1878783420), Locale.US, TimeZone.getDefault(), format); NumberFormat nf = new DecimalFormat("###.##"); String v2 = nf.format(testFloat.floatValue()); Assert.assertEquals("100.19", v1); Assert.assertEquals("100.19", v2); }

      This class may be the cause:
      public static abstract class AbstractNumberConverter<S, T> extends AbstractLocalizedConverter<S, T> {

      It seems to drop the "format" string.

      Also, the method:
      protected String format(Float obj, NumberFormat nf) throws ConversionException {

      Should be made public to work around the issue if you want to , for example, provide the DecimalFormat to the converter.

      Attachments

        Activity

          People

            adrianc@hlmksw.com Adrian Crum
            bradsdavis Brad Davis
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: