To add this library to your project, you'll have to add the following dependency.
dependencies {
...
implementation 'com.github.appwise-labs:measurements:<Latest-Version>'
}
Following line can be used to define a Measurement with a Unit of kilograms.
val m1 = Measurement(0.2, UnitMass.kilograms)
In order to convert it to another unit (of the same unit type)
val m2 = m1.converted(UnitMass.pounds)
When you want to format the measurement to show it to the user you can call the format
function.
println(m1.format())
You can also make calculations with different measurements
val m1 = Measurement(0.2, UnitMass.kilograms)
val m2 = m1.converted(UnitMass.pounds)
val sum = m1 + m2
println(sum.format())
Which would result in "0.4 kg".