本文整理汇总了Java中tec.units.ri.unit.MetricPrefix类的典型用法代码示例。如果您正苦于以下问题:Java MetricPrefix类的具体用法?Java MetricPrefix怎么用?Java MetricPrefix使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MetricPrefix类属于tec.units.ri.unit包,在下文中一共展示了MetricPrefix类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import tec.units.ri.unit.MetricPrefix; //导入依赖的package包/类
public static void main(String[] args) {
Unit<Speed> kmh = MetricPrefix.KILO(Units.METRE).divide(Units.HOUR).asType(Speed.class);
// Unit<Velocity> kmh2 = SIPrefix.KILO(Units.METRE).multiply(UCUM.HOUR).asType(Velocity.class);
Unit<?> kmh3 = MetricPrefix.KILO(Units.METRE).multiply(Units.HOUR);
System.out.println(kmh);
// System.out.println(kmh2);
System.out.println(kmh3);
// System.out.println(UCUM.POUND);
// System.out.println(UCUM.POUND.getSymbol());
// System.out.println(UCUM.POUND.getName());
System.out.println(Units.KILOGRAM);
System.out.println(Units.KILOGRAM.getSymbol());
System.out.println(Units.KILOGRAM.getName());
System.out.println(Units.GRAM);
System.out.println(Units.GRAM.getSymbol());
System.out.println(Units.GRAM.getName());
// Unit<Dimensionless> d = Units.METRE.asType(Dimensionless.class);
// System.out.println(d);
System.out.println(Quantities.getQuantity(3.3, LITRE).toString());
System.out.println(Quantities.getQuantity(3.3, NANO(LITRE)).toString());
}
示例2: main
import tec.units.ri.unit.MetricPrefix; //导入依赖的package包/类
public static void main(String[] args) {
//System.out.println(DemoUnitSystem.WATTHOUR);
Quantity<Power> power = Quantities.getQuantity(1000, MetricPrefix.MILLI(Units.WATT));
Quantity<Time> time = Quantities.getQuantity(15, Units.MINUTE);
Quantity<Energy> energy = power.multiply(time).asType(Energy.class);
System.out.println(energy); //Ouput 15000.00 J/s·min -> correct
System.out.println(energy.to(Units.JOULE)); //Output 900.00 J -> correct
System.out.println(energy.to(WATTHOUR)); //Output expected: 0.25 Wh
System.out.println(energy.to(MetricPrefix.KILO(Units.JOULE))); //Output expected something like 0.90 kJ or 0.90 kNm
Quantity<Energy> result = energy.to(MetricPrefix.KILO(WATTHOUR));
System.out.println(result); //Output expected 0.00025 kWh
}