unitsofmeasurement / unit-ri

JSR 363 - Reference Implementation
Other
28 stars 18 forks source link

Small fix: Transformed units symbol #74

Closed solanvp closed 6 years ago

solanvp commented 6 years ago

Hi

When working with alternate unites like Feet, Fahrenheit and so on, a custom symbol can be used, but in the TransformedUnit constructor, the symbol is being ignored:

  public TransformedUnit(String symbol, Unit<Q> parentUnit, UnitConverter unitConverter) {
    this(null, parentUnit, parentUnit.getSystemUnit(), unitConverter);
  }

A simple change would really help out:

  public TransformedUnit(String symbol, Unit<Q> parentUnit, UnitConverter unitConverter) {
    this(symbol, parentUnit, parentUnit.getSystemUnit(), unitConverter);
  }

Thanks and regards

keilw commented 6 years ago

Please use the label() method of SimpleUnitFormat instead, in most cases TransformedUnit has no symbol by design, that doesn't mean the unit cannot have a label/visual representation.