I am using the reference implementation of JSR 363: API Units from maven (tec.units: unit-ri).
Now I have to add a few units, such as a teaspoon, fl oz, etc.
Im extends the Units class to add a new block as follows:
public static final Unit<Volume> TEASPOON = addUnit(new TransformedUnit<Volume>("tsp", CUBIC_METRE, new MultiplyConverter(0.000005)));
This seems to work for conversion, but "tsp" is not parsed, so how do I add it to the parser?
And I had problems adding Fahrenheit, for example: T (° F) = T (K) × 9/5 - 459.67
How to do this with converters, or do I need to expand UnitConverter and create my own?
source share