Skip to content

Latest commit

 

History

History

springbootdemo

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Units of Measurement (JSR-385) Spring Boot demo

This is a small demo to demonstrate unit and prefix conversion using the RI of JSR-385 in a Spring Boot application.

Usage (using HTTPie)

http POST http://localhost:7070/conversion value=80 prefix=KILO unit=g targetPrefix=MILLI targetUnit=g

value is the value to convert

prefix and targetPrefix are valid String representation values from javax.measure.MetricPrefix

unit and targetUnit are valid String representation values from tech.units.indriya.unit.Units

Source and target units/prefixes should be compatible (e.g. can't convert from grams to meters) or it will result in a bad request.

The response will look similar to the output below:

{
    "input": {
        "prefix": "KILO",
        "targetPrefix": "MILLI",
        "targetUnit": "g",
        "unit": "g",
        "value": 80
    },
    "targetValue": 80000000.0
}

Original reference

The original repository that was created during our Adopt-a-JSR Day can be found here.

Postman

In src/etc you find a Postman collection to test the service.

Contributors

NLxAROSA koaben
NLxAROSA koaben