Wednesday, March 9, 2011

UOM Units Of Measure and Conversions in Java

some interesting facts on MAJOR disasters happened because of UOM / Conversion issues:

http://www.slideshare.net/keilw/eclipse-uomo

Here the Project's homepage

Here http://jscience.org/api/index.html?javax/measure/units/package-summary.html the javax.measure.units package

In doubt, I think I will implement a poor man's version of the framework:

enum UOM { KGM, CMT };

UOMValue {
  UOM uom;
  BigDecimal value;
  UOMValue convertTo(UOM targetUOM);
}

and do a switch with hardcoded conversion values.

Some cases which don't fit:

Size is composed by 3 values (len, wid, hei), which have the same UOM.

No comments: