{"id":22061234,"url":"https://github.com/netomi/uom","last_synced_at":"2025-05-12T21:58:14.178Z","repository":{"id":141736764,"uuid":"245968517","full_name":"netomi/uom","owner":"netomi","description":"A library to represent quantities and perform conversions between units of measurements with double or arbitray precision.","archived":false,"fork":false,"pushed_at":"2022-10-17T11:39:01.000Z","size":13911,"stargazers_count":10,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-01T04:04:12.524Z","etag":null,"topics":["java","units-converter","units-of-measurement","unitsofmeasurement"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/netomi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"netomi"}},"created_at":"2020-03-09T07:20:29.000Z","updated_at":"2024-05-17T16:50:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"f904748d-aa37-4927-aee8-7d2a1763319b","html_url":"https://github.com/netomi/uom","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netomi%2Fuom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netomi%2Fuom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netomi%2Fuom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netomi%2Fuom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/netomi","download_url":"https://codeload.github.com/netomi/uom/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253830911,"owners_count":21971001,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","units-converter","units-of-measurement","unitsofmeasurement"],"created_at":"2024-11-30T18:10:28.994Z","updated_at":"2025-05-12T21:58:14.171Z","avatar_url":"https://github.com/netomi.png","language":"Java","funding_links":["https://github.com/sponsors/netomi"],"categories":[],"sub_categories":[],"readme":"# Units of Measurement\n\n[![Build Status](https://api.travis-ci.org/netomi/uom.svg?branch=master)](https://travis-ci.org/netomi/uom)\n[![Coverage Status](https://coveralls.io/repos/github/netomi/uom/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/netomi/uom?branch=master)\n[![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/https/oss.sonatype.org/com.github.netomi/uom.svg)](https://oss.sonatype.org/content/repositories/snapshots/com/github/netomi/uom/)\n[![License](http://img.shields.io/:license-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)\n\nMy personal take on a _units of measurement_ library for java.\n\nThe design goal of the library is to include:\n\n* fully typed quantities:\n  ```java\n  Length l1 = Length.of(1, SI.METRE);\n  Length l2 = Length.ofMeter(2);          // convenience factory method for SI unit \n  ```\n* transparent support for double and arbitrary decimal precision quantities (using BigDecimal):\n  ```java\n  Length l1 = Quantities.create(1, SI.METRE);\n  Length l2 = Quantities.create(BigDecimal.ONE, Intl.YARD);\n  \n  Length l3 = l1.add(l2);   // quantities with different precision can be used together\n  ```\n* support for generic quantities:\n  ```java\n    Quantity\u003cSpeed\u003e speed = Quantities.createGeneric(1, SI.METER_PER_SECOND);\n  \n    System.out.println(speed.add(Speed.ofMeterPerSecond(2))); // -\u003e prints 3 m/s\n  ```\n* support for quantity factories:\n  ```java\n    QuantityFactory\u003cLength\u003e factory = DoubleQuantity.factory(Length.class);\n  \n    Length l1 = factory.create(1, SI.METRE);\n  \n    // default factories can be replaced\n    // use decimal precision with MathContext DECIMAL128 for every quantity of type Length:\n    Quantities.registerQuantityFactory(Length.class, DecimalQuantity.factory(MathContext.DECIMAL128, Length.class));\n  \n    // quantity factories with pooling behavior can be registered\n    QuantityFactory\u003cLength\u003e myPoolFactory = ...;\n    Quantities.registerQuantityFactory(Length.class, myPoolFactory);\n  ```  \n* support for the standard unit manipulations as defined by [JSR-385](https://www.jcp.org/en/jsr/detail?id=385) et al\n* support for as many units as possible, the amazing [GNU units](https://www.gnu.org/software/units/) library is the reference to compare to\n\nThe library uses dynamic proxies to create concrete quantity classes for the specified\nprecision at runtime.\n\n## Examples\n\nConversion of units between different system of units, e.g. SI and CGS\n\n```java\nElectricCharge e1 = ElectricCharge.of(1, SI.COULOMB);\nElectricCharge e2 = e1.to(ESU.STATCOULOMB);\n\nSystem.out.println(e2);\n```\n\nprints \n\n```2.997925e+09 statC```\n\n\nCustom quantities and units:\n\n```java\n    public interface Bmi extends Quantity\u003cBmi\u003e {}\n\n    ...\n\n    final Unit\u003cBmi\u003e bmiUnit = SI.KILOGRAM.divide(SI.METRE.pow(2)).withSymbol(\"B\").forQuantity(Bmi.class);\n    Quantity\u003cBmi\u003e bmiDouble  = Quantities.createGeneric(19, bmiUnit);\n    Quantity\u003cBmi\u003e bmiDecimal = Quantities.createGeneric(BigDecimal.valueOf(21), bmiUnit);\n\n    System.out.println(bmiDouble);\n```\n\nLicense\n-------\nCode is under the [Apache Licence v2](https://www.apache.org/licenses/LICENSE-2.0.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetomi%2Fuom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetomi%2Fuom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetomi%2Fuom/lists"}