JSR 363 RI User Guide
  • Introduction
  • Overview
  • Supported Units
  • Abstract Base Classes
    • Abstract Quantity
    • AbstractUnit
  • Factory Accessors
    • Units
    • Quantities
  • Library
  • Formatting
  • Functional Elements
    • Conversion
  • RI Level SPI
    • Measurement Interface
    • Range Class
  • Non Functional Requirements
    • Preserving precision
  • Examples
    • Hurricane Wind Scale
    • Using Enums
Powered by GitBook
On this page
  • Units
  • Metric Prefix
  1. Factory Accessors

Units

PreviousFactory AccessorsNextQuantities

Last updated 7 years ago

Units

The Units class extends AbstractSystemOfUnits and provides a set of a set of static constants for the most common units defined by SI/BIPM, see .

Metric Prefix

MetricPrefix is provided for obtaining multiples or submultiples of system units. Method names mirror SI / Metric prefix names but are uppercase like it's common to constants in Java. MetricPrefix is a "hybrid" enum, defining the constant factors as enumeration elements, but doing the actual conversion via matching static method names like CENTI, MEGA, etc.

Examples:

Unit<Length> m  = Units.METRE;
Unit<Length> km = MetricPrefix.KILO(Units.METRE);
Unit<Energy> kW = MetricPrefix.KILO(Units.WATT);

Unit instances returned by one of these methods provide type safety through unit parameterization (the and type parameters). This feature was discussed in the chapter of the specification.

Supported Units
Unit Parametrization