The Caliper library project manages units of measure and conversions between them. Caliper is designed to be lightweight and simple to use, yet comprehensive. It includes a large number of pre-defined units of measure commonly found in science, engineering, technology, finance and the household. These recognized systems of measurement include the International System of Units (SI), International Customary, United States and British Imperial. Custom units of measure can also be created in the Caliper unified measurement system. Custom units are specific to a trade or industry such as industrial packaging where units of can, bottle, case and pallet are typical. Custom units can be added to the unified system for units that are not pre-defined. This java library is used in an OEE project that can be found at https://github.com/point85/OEE-Designer. The Caliper library is also available in C# at https://github.com/point85/CaliperSharp.
A Caliper measurement system is a collection of units of measure where each pair has a linear relationship, i.e. y = ax + b where 'x' is the abscissa unit to be converted, 'y' (the ordinate) is the converted unit, 'a' is the scaling factor and 'b' is the offset. In the absence of a defined conversion, a unit will always have a conversion to itself. A bridge unit conversion is defined to convert between the fundamental SI and International customary units of mass (i.e. kilogram to pound mass), length (i.e. metre to foot) and temperature (i.e. Kelvin to Rankine). These three bridge conversions permit unit of measure conversions between the two systems. A custom unit can define any bridge conversion such as a bottle to US fluid ounces or litres.
The diagram below illustrates these concepts.

All units are owned by the unified measurement system. Units 'x' and 'y' belong to a relational system (such as SI or International Customary). Units 'w' and 'z' belong to a second relational system. Unit 'y' has a linear conversion to unit 'x'; therefore 'x' must be defined before 'y' can be defined. Unit 'x' is also related to 'y' by x = (y - b)/a. Unit 'w' has a conversion to unit 'z'. Unit 'z' is related to itself by z = z + 0. Unit 'x' has a bridge conversion defined to unit 'z' (for example a foot to a metre). Note that a bridge conversion from 'z' to 'x' is not necessary since it is the inverse of the conversion from 'x' to 'z'.
Scalar Unit
A simple unit, for example a metre, is defined as a scalar UOM. A special scalar unit of measure is unity or dimensionless "1".
Product Unit
A unit of measure that is the product of two other units is defined as a product UOM. An example is a Joule which is a Newton-metre.
Quotient Unit
A unit of measure that is the quotient of two other units is defined as a quotient UOM. An example is a velocity, e.g. metre/second.
Power Unit
A unit of measure that has an exponent on a base unit is defined as a power UOM. An example is area in metre^2. Note that an exponent of 0 is unity, and an exponent of 1 is the base unit itself. An exponent of 2 is a product unit where the multiplier and multiplicand are the base unit. A power of -1 is a quotient unit of measure where the dividend is 1 and the divisor is the base unit.
Type
Units are classified by type, e.g. length, mass, time and temperature. Only units of the same type can be converted to one another. Pre-defined units of measure are also enumerated, e.g. kilogram, Newton, metre, etc. Custom units (e.g. a 1 litre bottle) do not have a pre-defined type or enumeration and are referred to by a unique base symbol.
Base Symbol
All units have a base symbol that is the most reduced form of the unit. For example, a Newton is kilogram-metre/second^2. The base symbol is used in the measurement system to register each unit and to discern the result of arithmetic operations on quantities. For example, dividing a quantity of Newton-metres by a quantity of metres results in a quantity of Newtons.
Quantity
A quantity is an amount (implemented as a double precision number) together with a unit of measure. When arithmetic operations are performed on quantities, the original units can be transformed. For example, multiplying a length quantity in metres by a force quantity in Newtons results in a quantity of energy in Joules (or Newton-metres).
Product of Powers
A unit of measure is represented internally as a product of two other power units of measure:
For a simple scalar UOM (e.g. kilogram), both of the UOMs are null with the exponents defaulted to 0. For a product UOM (e.g. Newton), the first UOM is the multiplier and the second is the multiplicand with both exponents set to 1. For a quotient UOM (e.g. kilograms/hour), the first UOM is the dividend and the second is the divisor. The dividend has an exponent of 1 and the divisor an exponent of -1. For a power UOM (e.g. square metres), the first UOM is the base and the exponent is the power. In this case, the second UOM is null with the exponent defaulted to 0.
From the two power products, a unit of measure can then be recursively reduced to a map of base units of measure and corresponding exponents along with a scaling factor. For example, a Newton reduces to (kg, 1), (m, 1), (s, -2) in the SI system. Multiplying, dividing and converting a unit of measure is accomplished by merging the two maps (i.e. "cancelling out" units) and then computing the overall scaling factor. The base symbol is obtained directly from the final map.
The singleton unified MeasurementSystem is obtained by calling:
MeasurementSystemsys = MeasurementSystem.getSystem();The Unit.properties file defines the name, symbol, description and UCUM symbol for each of the predefined units in the following code examples. The Unit.properties file is localizable. For example, 'metres' can be changed to use the US spelling 'meters' or descriptions can be translated to another language.
The metre scalar UOM is created by the MeasurementSystem as follows:
UnitOfMeasureuom = createScalarUOM(UnitType.LENGTH, Unit.METRE, symbols.getString("m.name"),
symbols.getString("m.symbol"), symbols.getString("m.desc"));The square metre power UOM is created by the MeasurementSystem as follows:
UnitOfMeasureuom = createPowerUOM(UnitType.AREA, Unit.SQUARE_METRE, symbols.getString("m2.name"),
symbols.getString("m2.symbol"), symbols.getString("m2.desc"), getUOM(Unit.METRE), 2);The metre per second quotient UOM is created by the MeasurementSystem as follows:
UnitOfMeasureuom = createQuotientUOM(UnitType.VELOCITY, Unit.METRE_PER_SEC, symbols.getString("mps.name"), symbols.getString("mps.symbol"), symbols.getString("mps.desc"), getUOM(Unit.METRE), getSecond());The Newton product UOM is created by the MeasurementSystem as follows:
UnitOfMeasureuom = createProductUOM(UnitType.FORCE, Unit.NEWTON, symbols.getString("newton.name"),
symbols.getString("newton.symbol"), symbols.getString("newton.desc"),
getUOM(Unit.KILOGRAM), getUOM(Unit.METRE_PER_SECOND_SQUARED));A millisecond is 1/1000th of a second with a defined prefix and created as:
UnitOfMeasuresecond = sys.getSecond();
UnitOfMeasuremsec = sys.getUOM(Prefix.MILLI, second);For a second example, a US gallon = 231 cubic inches:
UnitOfMeasureuom = createScalarUOM(UnitType.VOLUME, Unit.US_GALLON, symbols.getString("us_gallon.name"),
symbols.getString("us_gallon.symbol"), symbols.getString("us_gallon.desc"));
uom.setConversion(231d, getUOM(Unit.CUBIC_INCH));When creating the foot unit of measure in the unified measurement system, a bridge conversion to metre is defined (1 foot = 0.3048m):
UnitOfMeasureuom = createScalarUOM(UnitType.LENGTH, Unit.FOOT, symbols.getString("foot.name"),
symbols.getString("foot.symbol"), symbols.getString("foot.desc"));
// bridge to SIuom.setBridgeConversion(0.3048, getUOM(Unit.METRE), 0);Custom units and conversions can also be created:
// gallons per hourUnitOfMeasuregph = sys.createQuotientUOM(UnitType.VOLUMETRIC_FLOW, "gph", "gal/hr", "gallons per hour", sys.getUOM(Unit.US_GALLON), sys.getHour());
// 1 16 oz can = 16 fl. oz.UnitOfMeasureone16ozCan = sys.createScalarUOM(UnitType.VOLUME, "16 oz can", "16ozCan", "16 oz can");
one16ozCan.setConversion(16d, sys.getUOM(Unit.US_FLUID_OUNCE));
// 400 cans = 50 US gallonsQuantityq400 = newQuantity(400d, one16ozCan);
Quantityq50 = q400.convert(sys.getUOM(Unit.US_GALLON));
// 1 12 oz can = 12 fl.oz.UnitOfMeasureone12ozCan = sys.createScalarUOM(UnitType.VOLUME, "12 oz can", "12ozCan", "12 oz can");
one12ozCan.setConversion(12d, sys.getUOM(Unit.US_FLUID_OUNCE));
// 48 12 oz cans = 36 16 oz cansQuantityq48 = newQuantity(48d, one12ozCan);
Quantityq36 = q48.convert(one16ozCan);
// 6 12 oz cans = 1 6-pack of 12 oz cansUnitOfMeasuresixPackCan = sys.createScalarUOM(UnitType.VOLUME, "6-pack", "6PCan", "6-pack of 12 oz cans");
sixPackCan.setConversion(6d, one12ozCan); // 1 case = 4 6-packsUnitOfMeasurefourPackCase = sys.createScalarUOM(UnitType.VOLUME, "6-pack case", "4PCase", "four 6-packs");
fourPackCase.setConversion(4d, sixPackCan);
// A beer bottling line is rated at 2000 12 ounce cans/hour (US) at the// filler. The case packer packs four 6-packs of cans into a case.// Assuming no losses, what should be the rating of the case packer in// cases per hour? And, what is the draw-down rate on the holding tank// in gallons/minute?UnitOfMeasurecanph = sys.createQuotientUOM(one12ozCan, sys.getHour());
UnitOfMeasurecaseph = sys.createQuotientUOM(fourPackCase, sys.getHour());
UnitOfMeasuregpm = sys.createQuotientUOM(sys.getUOM(Unit.US_GALLON), sys.getMinute());
// filler production rateQuantityfiller = newQuantity(2000d, canph);
// tank draw-downQuantitydraw = filler.convert(gpm);
// case packer productionQuantitypacker = filler.convert(caseph);Quantities can be added, subtracted and converted:
UnitOfMeasurem = sys.getUOM(Unit.METRE);
UnitOfMeasurecm = sys.getUOM(Prefix.CENTI, m);
Quantityq1 = newQuantity(2d, m);
Quantityq2 = newQuantity(2d, cm);
// add two quantities. q3 is 2.02 metreQuantityq3 = q1.add(q2);
// q4 is 202 cmQuantityq4 = q3.convert(cm);
// subtract q1 from q3 to get 0.02 metreq3 = q3.subtract(q1);as well as multiplied and divided:
Quantityq1 = newQuantity(50d, cm);
Quantityq2 = newQuantity(50d, cm);
// q3 = 2500 cm^2Quantityq3 = q1.multiply(q2);
// q4 = 50 cmQuantityq4 = q3.divide(q1);and inverted:
UnitOfMeasuremps = sys.getUOM(Unit.METRE_PER_SECOND); Quantityq1 = newQuantity(10d, mps);
// q2 = 0.1 sec/mQuantityq2 = q1.invert();To make working with linearly scaled units of measure (with no offset) easier, the MeasurementSystem's getUOM() using a Prefix can be used. This method accepts a Prefix enum and the unit of measure that it is scaled against. The resulting unit of measure has a name concatented with the Prefix's name and target unit name. The symbol is formed similarly. For example, a centilitre (cL) is created from the pre-defined litre by:
UnitOfMeasurelitre = sys.getUOM(Unit.LITRE);
UnitOfMeasurecL = sys.getUOM(Prefix.CENTI, litre);and, a megabyte (MB = 2^20 bytes) is created by:
UnitOfMeasuremB = sys.getUOM(Prefix.MEBI, Unit.BYTE);Implicit Conversions
A quantity can be converted to another unit of measure without requiring the target UOM to first be created. If the quantity has a product or quotient UOM, use the convertToPowerProduct() method. For example:
// convert 1 newton-metre to pound force-inchesQuantitynmQ = newQuantity(1.0, sys.getUOM(Unit.NEWTON_METRE));
QuantitylbfinQ = nmQ.convertToPowerProduct(sys.getUOM(Unit.POUND_FORCE), sys.getUOM(Unit.INCH));If the quantity has power UOM, use the convertToPower() method. For example:
// convert 1 square metre to square inchesQuantitym2Q = newQuantity(1.0, sys.getUOM(Unit.SQUARE_METRE));
Quantityin2Q = m2Q.convertToPower(sys.getUOM(Unit.INCH));Other UOMs can be converted using the convert() method.
Classification
During arithmetic operations, the final type of the unit may not be known. In this case, invoking the classify() method will attempt to find a matching unit type. For example, the calculated unit of measure below has a type of UnitType.ELECTRIC_CAPACITANCE:
UnitOfMeasures = sys.getSecond();
UnitOfMeasurem = sys.getUOM(Unit.METRE);
UnitOfMeasurekg = sys.getUOM(Unit.KILOGRAM);
UnitOfMeasureamp = sys.getUOM(Unit.AMPERE);
UnitOfMeasurecap = s.power(-3).multiply(amp.power(-2)).multiply(m.power(2)).divide(kg).classify();A quantity resulting from an arithmetic operation can also be classified. For example, the "density" quantity has UnitType.DENSITY:
Quantitymass = newQuantity(1035, Unit.KILOGRAM);
Quantityvolume = newQuantity(1000, Unit.LITRE);
Quantitydensity = mass.divide(volume).classify();Water boils at 100 degrees Celcius. What is this temperature in Fahrenheit?
QuantityqC = newQuantity(100.0, Unit.CELSIUS);
QuantityqF = qC.convert(Unit.FAHRENHEIT);A nutrition label states the energy content is 1718 KJ. What is this amount in kilo-calories?
Quantitykcal = newQuantity(1718, Prefix.KILO, Unit.JOULE).convert(Prefix.KILO, Unit.CALORIE);One's Body Mass Index (BMI) can be calculated as:
Quantityheight = newQuantity(2d, Unit.METRE);
Quantitymass = newQuantity(100d, Unit.KILOGRAM);
Quantitybmi = mass.divide(height.multiply(height));Einstein's famous E = mc^2:
Quantityc = sys.getQuantity(Constant.LIGHT_VELOCITY);
Quantitym = newQuantity(1.0, Unit.KILOGRAM);
Quantitye = m.multiply(c).multiply(c);// A Tesla Model S battery has a capacity of 100 KwH. // When fully charged, how many electrons are in the battery?Quantityc = sys.getQuantity(Constant.LIGHT_VELOCITY);
Quantityme = sys.getQuantity(Constant.ELECTRON_MASS); Quantitykwh = newQuantity(100, Prefix.KILO, Unit.WATT_HOUR);
Quantityelectrons = kwh.divide(c).divide(c).divide(me);Ideal Gas Law, PV = nRT. A cylinder of argon gas contains 50.0 L of Ar at 18.4 atm and 127 -C. How many moles of argon are in the cylinder?
Quantityp = newQuantity(18.4, Unit.ATMOSPHERE).convert(Unit.PASCAL);
Quantityv = newQuantity(50d, Unit.LITRE).convert(Unit.CUBIC_METRE);
Quantityt = newQuantity(127d, Unit.CELSIUS).convert(Unit.KELVIN);
Quantityn = p.multiply(v).divide(sys.getQuantity(Constant.GAS_CONSTANT).multiply(t));Photon energy using Planck's constant:
// energy of red light photon = Planck's constant times the frequencyQuantityfrequency = newQuantity(400d, sys.getUOM(Prefix.TERA, Unit.HERTZ));
Quantityev = sys.getQuantity(Constant.PLANCK_CONSTANT).multiply(frequency).convert(Unit.ELECTRON_VOLT);
// and wavelength of red light in nanometres (approx 749.48)Quantitywavelength = sys.getQuantity(Constant.LIGHT_VELOCITY).divide(frequency).convert(sys.getUOM(Prefix.NANO, Unit.METRE));Newton's second law of motion (F = ma). Weight of 1 kg in lbf:
Quantitymkg = newQuantity(1d, Unit.KILOGRAM);
Quantityf = mkg.multiply(sys.getQuantity(Constant.GRAVITY)).convert(Unit.POUND_FORCE);Units per volume of solution, C = A x (m/V)
// create the "A" unit of measureUnitOfMeasureactivityUnit = sys.createQuotientUOM(UnitType.UNCLASSIFIED, "activity", "act",
"activity of material", sys.getUOM(Unit.UNIT), sys.getUOM(Prefix.MILLI, Unit.GRAM));
// calculate concentrationQuantityactivity = newQuantity(1d, activityUnit);
Quantitygrams = newQuantity(1d, Unit.GRAM).convert(Prefix.MILLI, Unit.GRAM);
Quantityvolume = newQuantity(1d, sys.getUOM(Prefix.MILLI, Unit.LITRE));
Quantityconcentration = activity.multiply(grams.divide(volume));
Quantitykatals = concentration.multiply(newQuantity(1d, Unit.LITRE)).convert(Unit.KATAL);Black body radiation:
// The Stefan-Boltzmann law states that the power emitted per unit area// of the surface of a black body is directly proportional to the fourth// power of its absolute temperature: sigma * T^4// calculate at 1000 KelvinQuantitytemp = newQuantity(1000.0, Unit.KELVIN);
Quantityintensity = sys.getQuantity(Constant.STEFAN_BOLTZMANN).multiply(temp.power(4));Expansion of the universe:
// Hubble's law, v = H0 x D. Let D = 10 MpcQuantityd = newQuantity(10d, sys.getUOM(Prefix.MEGA, sys.getUOM(Unit.PARSEC)));
Quantityh0 = sys.getQuantity(Constant.HUBBLE_CONSTANT);
Quantityvelocity = h0.multiply(d);Device Characteristic Life
// A device has an activation energy of 0.5 and a characteristic life of// 2,750 hours at an accelerated temperature of 150 degrees Celsius.// Calculate the characteristic life at an expected use temperature of// 85 degrees Celsius.// Convert the Boltzman constant from J/K to eV/K for the Arrhenius equationQuantityj = newQuantity(1d, Unit.JOULE);
QuantityeV = j.convert(Unit.ELECTRON_VOLT);
// Boltzmann constantQuantityKb = sys.getQuantity(Constant.BOLTZMANN_CONSTANT).multiply(eV.getAmount());
// accelerated temperatureQuantityTa = newQuantity(150d, Unit.CELSIUS);
// expected use temperatureQuantityTu = newQuantity(85d, Unit.CELSIUS);
// calculate the acceleration factorQuantityfactor1 = Tu.convert(Unit.KELVIN).invert().subtract(Ta.convert(Unit.KELVIN).invert());
Quantityfactor2 = Kb.invert().multiply(0.5);
Quantityfactor3 = factor1.multiply(factor2);
doubleAF = Math.exp(factor3.getAmount());
// calculate longer life at expected use temperatureQuantitylife85 = newQuantity(2750d, Unit.HOUR);
Quantitylife150 = life85.multiply(AF);Value of a stock portfolio:
// John has 100 shares of Alphabet Class A stock. How much is his// portfolio worth in euros when the last trade was $838.96 and a US// dollar is worth 0.94 euros?UnitOfMeasureeuro = sys.getUOM(Unit.EURO);
UnitOfMeasureusd = sys.getUOM(Unit.US_DOLLAR);
usd.setConversion(0.94, euro);
UnitOfMeasuregoogl = sys.createScalarUOM(UnitType.CURRENCY, "Alphabet A", "GOOGL",
"Alphabet (formerly Google) Class A shares");
googl.setConversion(838.96, usd);
Quantityportfolio = newQuantity(100, googl);
Quantityvalue = portfolio.convert(euro);// convert Unit to nanokatalUnitOfMeasureu = sys.getUOM(Unit.UNIT);
UnitOfMeasurekatal = sys.getUOM(Unit.KATAL);
Quantityq1 = newQuantity(1.0, u);
Quantityq2 = q1.convert(sys.getUOM(Prefix.NANO, katal));
// test result EquivalentUnitOfMeasureeq = sys.getUOM(Unit.EQUIVALENT);
UnitOfMeasurelitre = sys.getUOM(Unit.LITRE);
UnitOfMeasuremEqPerL = sys.createQuotientUOM(UnitType.MOLAR_CONCENTRATION, "milliNormal", "mEq/L",
"solute per litre of solvent ", sys.getUOM(Prefix.MILLI, eq), litre);
QuantitytestResult = newQuantity(5.0, mEqPerL);
// blood cell count test resultsUnitOfMeasurek = sys.getUOM(Prefix.KILO, sys.getOne());
UnitOfMeasureuL = sys.getUOM(Prefix.MICRO, Unit.LITRE);
UnitOfMeasurekul = sys.createQuotientUOM(UnitType.MOLAR_CONCENTRATION, "K/uL", "K/uL",
"thousands per microlitre", k, uL);
testResult = newQuantity(7.0, kul);
UnitOfMeasurefL = sys.getUOM(Prefix.FEMTO, Unit.LITRE);
testResult = newQuantity(90d, fL);
// TSH test resultUnitOfMeasureuIU = sys.getUOM(Prefix.MICRO, Unit.INTERNATIONAL_UNIT);
UnitOfMeasuremL = sys.getUOM(Prefix.MILLI, Unit.LITRE);
UnitOfMeasureuiuPerml = sys.createQuotientUOM(UnitType.MOLAR_CONCENTRATION, "uIU/mL", "uIU/mL",
"micro IU per millilitre", uIU, mL);
testResult = newQuantity(2.0, uiuPerml);// convert 74 inches to feet and inchesQuantityqHeight = newQuantity(74, Unit.INCH);
List<UnitOfMeasure> uoms = newArrayList<>();
uoms.add(sys.getUOM(Unit.FOOT));
uoms.add(sys.getUOM(Unit.INCH));
List<Quantity> converted = qHeight.convert(uoms);In general, Caliper does not support conversion of mixed units of measure. For example, if customary and SI units appear together in either a quotient or product unit of measurement (e.g. density in kilogram/cubic foot), conversion to another consistent unit of measure (e.g. density in lbm/litre) requires a case-by-case solution. The practical case below from the mining and precious metals industry illustrates this approach.
Caliper defines a troy ounce (troyOz) as 0.06857142857 pound-mass. Now define the pennyweight based on a troy ounce where sys = MeasurementSystem.instance():
UnitOfMeasurepennyweight = sys.createScalarUOM(UnitType.MASS, "pennyweight", "dwt", "Pennyweight");
pennyweight.setConversion(0.05, troyOz);Now create a unitless quotient UOM for metal grade:
UnitOfMeasurepennyweightPerShortTon = sys.createQuotientUOM(pennyweight, sys.getUOM(Unit.US_TON)); Let's convert a precious metal grade defined in SI units to pennyweight customary units:
UnitOfMeasuregramsPerTonne = sys.createQuotientUOM(sys.getUOM(Unit.GRAM), sys.getUOM(Unit.TONNE));
QuantityqGrade = newQuantity(0.95, gramsPerTonne); QuantityqGradeConverted = qGrade.convert(pennyweightPerShortTon);The converted grade is about 0.554167. These conversions work since the quotient units are defined within a consistent system (SI and Customary in this example).
Now suppose we want to convert a mixed unit grade in grams per metric tonne to troy ounces per metric tonne. This will require defining another troy ounce based on grams:
UnitOfMeasuretroyOzSI = sys.createScalarUOM(UnitType.MASS, "troy ounce SI", "troy oz", "Troy ounce SI conversion");
troyOzSI.setConversion(31.1034768, sys.getUOM(Unit.GRAM));
UnitOfMeasuretroyOzPerTonne = sys.createQuotientUOM(troyOzSI, sys.getUOM(Unit.TONNE));
QuantityqGradeConverted = qGrade.convert(troyOzPerTonne);The grade when converted to troyOzPerTonne is about 0.0305432.
The new kilogram is defined based on Planck's constan. It can be understood as the mass difference of the number of cesium-133 atoms in the ground state versus the same number in the excited hyperfine state. Or, or as the mass of the number of photons at the Cesium-133 hyperfine frequency trapped in a microwave cavity.
What is this number?
This number can be calculated from Plancks' constant (h), the definition of a second in terms of ∆νCs: the hyperfine transition frequency of cesium-133 and the speed of light in a vacuum, and the speed of light in a vacuum (c):
count/kg = c^2 / (h * ∆νCs)
The Java calculation for 1.475521E40/kg is
MeasurementSystemsys = MeasurementSystem.getSystem();
// Planck's constantQuantityplanck = sys.getQuantity(Constant.PLANCK_CONSTANT);
System.out.println(planck);
// cesium-133 hyperfine transition frequencyQuantityvCs = newQuantity(9.192631770E+09, Unit.HERTZ);
System.out.println(vCs);
// speed of lightQuantityc = sys.getQuantity(Constant.LIGHT_VELOCITY);
System.out.println(c);
// number of cesium 133 atoms in a kilogramQuantitykgCount = c.power(2).divide(planck.multiply(vCs));
System.out.println(kgCount);with output:
6.62607015E-34, [Type: UNCLASSIFIED, Symbol: J·s, Conversion: J·s, BaseSymbol: kg·m²/s] (hc, Planck's constant, Planck'sconstant)
9.19263177E9, [Type: FREQUENCY, Enumeration: HERTZ, Symbol: Hz, Conversion: Hz, BaseSymbol: 1/s] 2.99792458E8, [Type: VELOCITY, Enumeration: METRE_PER_SEC, Symbol: m/s, Conversion: m/s, BaseSymbol: m/s] (c, Vc, velocityoflightinavacuum)
1.475521399735271E40, [Type: UNCLASSIFIED, Symbol: m/s^2/J·s·Hz, Conversion: m/s^2/J·s·Hz, BaseSymbol: 1/kg] A unit of measure once created is registered in two hashmaps, one by its base symbol key and the second one by its enumeration key. Caching greatly increases performance since the unit of measure is created only once. Methods are provided to clear the cache of all instances as well as to unregister a particular instance.
The double value of a unit of measure conversion is also cached. This performance optimization eliminates the need to calculate the conversion multiple times if many quantities are being converted at once; for example, operations upon a vector or matrix of quantities all with the same unit of measure.
All externally visible text is defined in two resource bundle .properties files. The Unit.properties file has the name (.name), symbol (.symbol) and description (.desc) for a unit of measure as well as toString() method text. The Message.properties file has the text for an exception. A default English file for each is included in the project. The files can be translated to another language by following the Java locale naming conventions for the properties file, or the English version can be edited, e.g. to change "metre" to "meter". For example, a metre's text is:
# metrem.name = metrem.symbol = mm.desc = Thelengthofthepathtravelledbylightinvacuumduringatimeintervalof1/299792458ofasecond.and for an exception:
already.created = Theunitofmeasurewithsymbol {0} hasalreadybeencreatedby {1}. Didyouintendtoscalethisunitwithalinearconversion?The Caliper library depends on Java 11+. The unit tests depend on JUnit (http://junit.org/junit4/), Hamcrest (http://hamcrest.org/), Gson (https://github.com/google/gson) and HTTP Request (https://github.com/kevinsawicki/http-request).
The Maven repository is:
<dependency>
<groupId>io.github.point85</groupId>
<artifactId>caliper</artifactId>
<version>1.2.8</version>
</dependency>JSR 363 "proposes to establish safe and useful methods for modeling physical quantities" (https://java.net/downloads/unitsofmeasurement/JSR363Specification_EDR.pdf). Caliper shares many of the underlying aspects of JSR 363. Caliper however does not use Java generics, and there is only one system of units. Caliper performs math using double amounts whereas JSR 363 uses Numbers.
The tables below compare the JSR 363 specification in the first column to Point85 in the second column.




