What API can I use to convert quantities between different units?


Need to convert a quantity in unit A to a different unit B. Unit B is convertible from unit A.


There is an api on Unit.c3typ called getConversionFactor to get the conversion factor and isConvertable to check if the two units can be converted to each other


But is there an API to give us the quantity in the target unit?


Seems like you need a function called convert from one unit to the other exposed via the Unit.c3typ. There isn’t one already but we should add one. Please file a ticket for it.

In the meanwhile you can use the getConversionFactor to manually get the value. The above function should eliminate the 1 line of code for you