jscience
  1. jscience
  2. JSCIENCE-145

MeasureFormat.NumberUnit.format() does not use NumberFormat with CompoundUnits

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: current
    • Fix Version/s: Version 6.0
    • Component/s: www
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      145

      Description

      To reproduce:
      1. Call MeasureFormat.getInstance() and pass in your own NumberFormat.
      MeasureFormat formatter = new DecimalFormat(" #,### "), UnitFormat.getInstance();

      2. Format a Measure that uses a Compound Unit
      Measure<Double, Length> measure =
      Measure.valueOf(23928.0,NonSI.MILE.compound(NonSI.FOOT));
      String str = formatter.format(measure);

      3. Note numbers don't end up being formatted according to the NumberFormat being
      passed in. In this case, it should read " 4 mi 2,808 ft" but instead reads
      "4mi2808ft"

      Probable bug cause:
      File: javax.measure.MeasureFormat.java
      Method: MeasureFormat.NumberUnit.formatCompound()
      Line 95: toAppendTo.append((long) value);

      Recommended fix:
      change line 95 to: _numberFormat.format((long) value, toAppendTo, pos);

        Activity

        Hide
        joust added a comment -

        Sorry, step 1 should read:
        MeasureFormat formatter = MeasureFormat.getInstance(new DecimalFormat(" #,###
        "), UnitFormat.getInstance());

        Show
        joust added a comment - Sorry, step 1 should read: MeasureFormat formatter = MeasureFormat.getInstance(new DecimalFormat(" #,### "), UnitFormat.getInstance());

          People

          • Assignee:
            jscience-issues
            Reporter:
            joust
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: