Use this tag for questions related to usage or extension of new units of measure standard JSR-363.
Questions tagged [jsr363]
16 questions
9
votes
1 answer
Jackson module signature prevents addings serializers for self-referencing generic types
I want to add a custom serializer and deserializer for JSR 363 javax.measure.Quantity
>, which basically encapsulates a "value" and a "unit". Creating the serializer (extends JsonSerializer>) and the deserializer…

Garret Wilson
- 18,219
- 30
- 144
- 272
7
votes
2 answers
JSR 363 adding new units
I am using the reference implementation of JSR 363: Units of Measurement API from maven (tec.units:unit-ri).
Now I have to add a few units like teaspoon, fluid ounce and so on.
Im extending the Units class to add a new unit like this:
public static…

TeKo
- 465
- 1
- 5
- 17
6
votes
4 answers
Java units of measurement library addition and subtraction returning incorrect values
I'm using the reference implementation of JSR363. I've tried many variations of this but I'll give this code as an example.
ServiceProvider provider = ServiceProvider.current();
QuantityFactory lengthFactory =…

zjuhasz
- 1,489
- 12
- 30
5
votes
1 answer
How can I change the label on a Unit using the Java Measurement API?
Problem Introduction
I'm trying to use this implementation of the Java Units of Measurement (JSR 363).
I would like to change the behavior of several of the provided units. An example of one is DEGREE_ANGLE, so that the degree symbol (°) is…

karobar
- 1,250
- 8
- 30
- 61
2
votes
1 answer
Unit Of Measures API (JSR-363) - Floating Point Errors
We are using tec.units.unit-ri as an implementation of the JSR-363, javax.measure.unit-api.
We are using several weight-, length- and temperature- types in our application and we decided to use BigDecimal to store them. While doing some…

javahippie
- 806
- 10
- 25
2
votes
1 answer
How to define custom unit (or predefined quantity) "roll" using JSR-363?
How can I define a custom unit called roll using JSR 363? How can I define it as a predefined quantity for length like one roll is always 250 meters? How can I define it as a totally separate base unit in case a roll doesn't have a fixed length?
I…

aycanadal
- 1,106
- 2
- 15
- 42
2
votes
1 answer
JSR 363 : formating a volume unit in decilitre
Formatting a volume unit works correctly in millilitres and centilitres but fails for decilitres.
import static tec.units.ri.unit.Units.LITRE;
import javax.measure.Unit;
import javax.measure.format.UnitFormat;
import…

C. Borgogno
- 21
- 2
2
votes
2 answers
UCUM UnitFormat for JSR 363
I'm using JSR 363 "Units of Measurement" with the latest reference implementation:
javax.measure
unit-api
1.0
…

Garret Wilson
- 18,219
- 30
- 144
- 272
2
votes
1 answer
unit conversion between mile and km using jsr 363 library
Hi I am new to using jsr 363 to do a unit conversion application. Can anyone help me to do the conversion between mile and km using jsr 363 library(uni-api)

Hariprasath
- 539
- 1
- 9
- 21
1
vote
1 answer
How can I determine if a javax.measure.Quantity is a Speed?
I have some code that uses the javax.measure API to compute the speed of an asset being tracked. I pass the Quantity object as a value into a JTable renderer and the generic parameter (Speed) has been erased. Even if the Speed parameter were there,…

Gene McCulley
- 1,097
- 1
- 10
- 15
1
vote
2 answers
How to compare two JSR-363 Quantity objects?
I'm trying to use JSR-363 Quantity to manage some quantities in my application. I have some code similar to the following that I would like to convert to use the Quantity class.
Double volume1 = 14d;
Double volume2 = 18d;
Assert.isTrue(volume1 <…

Mustafa
- 5,624
- 3
- 24
- 40
1
vote
1 answer
JScience unit of measurement library incompatible with android
I have a use-case in my android application where I need to save a quantity, perform calculations on it, and display it in a unit of the user's choice (from a predefined list).
JScience fit this need perfectly, but I cannot compile the application…

hxtk
- 325
- 1
- 9
1
vote
0 answers
UCUM representation of liter
I'm confused about how the UCUM defines the symbol for "liter". Yes I'm aware that historically the symbol l has been used, and that more recently L has been added by standards bodies (see e.g. BIPM SI 8th Edition) as an alternative to l. But I…

Garret Wilson
- 18,219
- 30
- 144
- 272
0
votes
1 answer
Setting an alias name on a ProductUnit fails to return that alias during serialization
Task
I am trying to set an alias name on a UOM ProductUnitto allow the unit to be displayed in a human-friendly name in JSON/my frontend. The unit in question is "kg/h", so a mass-flow rate derived from the SI basic units "kg" and "s".
However,…

Johannes Jander
- 4,974
- 2
- 31
- 46
0
votes
1 answer
unit-of-measurement filter by quantity
we are using the great unit-of-measurement framework to manage units dynamically. I have the requirement to filter a list of units by quantity. E.g. display all mass (tonne, kg ....). The list results in an generic capture list (which is not ideal -…

itstata
- 1,058
- 7
- 17