Can I use this API to convert beetween volume based measures to metric mass units ?

11 views
Skip to first unread message

cvga...@gmail.com

unread,
Feb 20, 2019, 10:30:07 AM2/20/19
to Units Users

Hello,

I just knew about JSR-385 today while looking for Mass and Volume converting APIs.

I'm in a need of a conversion API that allows me to convert Volume based measures (teaspoon, cup, etc) found in steps of Food Recipes to Mass units (grams) or Volume (mL). 

Also I'll need to convert between other mass and volume units: Kg -> g, Pound to g, Cup to mL, Litres to mL, etc.

It seems that in order to convert Volume to Mass I will need Specific Gravity of the measured substance.

It will be possible to work with non-SI units with this measure API ? 

thanks,

Cristiano

Werner Keil

unread,
Mar 11, 2019, 8:42:24 PM3/11/19
to Units Users
Hello Cristiano,

Thanks a lot for the message and your interest in using JSR 385.
Sorry for the slight delay, we have many work streams towards the Final release, but let me answer them.

Yes, you can convert volumes from non-SI units like teaspoon, cup, liquid ounce etc. to metric units like m3 or those accepted with the SI system like L and mL.

You can do the same with mass units like gram, stone, Pound, etc. 

To convert Volume to Mass or vice versa, this might help:

The relevant factor Density is part of SI Units.

Those and the wider (non-SI) collection of Unit Systems allow you to work with non-SI units through the same API.

In fact when you use those modules together with a compatible implementation (most are based on Indriya now, but before version 2 the API is still 1.0/JSR 363) the ServiceLoader of the Unit SPI will give you access to all supported Unit Systems.

If you're interested to explore a library or demos for those kitchen units, either https://github.com/unitsofmeasurement/uom-demos or https://github.com/unitsofmeasurement/uom-spaces (our incubator) would be a good place and you're welcome to participate there.

Regards,
Werner
Reply all
Reply to author
Forward
0 new messages