Dealing with unit conversion is always a pain point. At first, it seems simple enough until you hit the first edge-case. Just like with Date and Time (JSR 310), there’s a well-specified solution available, although not directly in the JDK: the Units of Measurement API (JSR 385).
There’s going to be a mix of British English (BE) and American English (AE) writing of unit names throughout the article, as the library I’m talking about uses BE for constants, etc. However, I’m used to writing AE, and most of my audience is most likely too.
Working with different units of measurement in our code can be challenging. While we have well-specified and standardized SI units, their consistent and correct use or conversion remains complex.
And the problem is getting worse when non-SI units, such as United States customary units or the Imperial units, are thrown into the mix.