我使用的是JSR 363“度量单位”和最新的参考实现:
<dependency>
<groupId>javax.measure</groupId>
<artifactId>unit-api</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>tec.units</groupId>
<artifactId>unit-ri</artifactId>
<version>1.0.2</version>
</dependency>我想打印出UCUM格式的“毫升”,即"mL":
final UnitFormat unitFormat =
ServiceProvider.current().getUnitFormatService().getUnitFormat();
final Unit<?> unit = MILLI(LITRE);
final String unitString=unitFormat.format(unit);不幸的是,这给了我"ml",而不是来自UCUM的"mL“。尽管JSR363规范(和源代码)自始至终都在引用UCUM,但RI上的UnitFormatService.getAvailableFormatNames()只给了我"ASCII“和"Default",所以我不能使用getUnitFormat("UCUM")作为JSR363规范提示我应该能够做到这一点(如果有人支持UCUM的话)。
那么,我可以从哪里获得支持UCUM的JSR363UCUM实现?
发布于 2017-04-25 17:38:34
有关UCUM支持,请参阅JSR363扩展模块https://github.com/unitsofmeasurement/uom-systems/tree/master/ucum-java8。
它提供了对JavaSE8上的统一度量单位代码的支持。目前,UCUM更加强大和广泛,解析使用SymbolMap概念(基于Java ResourceBundles,但它不是本地敏感的),因此我们不能将其用于JSR363RI。如果可以,请使用兼容的JavaSE8端口UoM SE。
发布于 2019-04-01 09:46:10
在UCUM中,l (小写ell)和L都用于liter。小写是欧洲大陆风格,大写是美国风格。两者在UCUM中是等效的。所以这只是一个风格问题。
https://stackoverflow.com/questions/42653545
复制相似问题