Class UnitFormat.DefaultFormat

    • Constructor Detail

      • DefaultFormat

        protected DefaultFormat()
    • Method Detail

      • label

        public void label​(Unit<?> unit,
                          String label)
        Description copied from class: UnitFormat
        Attaches a system-wide label to the specified unit. For example: [code] UnitFormat.getInstance().label(DAY.multiply(365), "year"); UnitFormat.getInstance().label(METER.multiply(0.3048), "ft"); [/code] If the specified label is already associated to an unit the previous association is discarded or ignored.
        Specified by:
        label in class UnitFormat
        Parameters:
        unit - the unit being labelled.
        label - the new label for this unit.
      • alias

        public void alias​(Unit<?> unit,
                          String alias)
        Description copied from class: UnitFormat
        Attaches a system-wide alias to this unit. Multiple aliases may be attached to the same unit. Aliases are used during parsing to recognize different variants of the same unit. For example: [code] UnitFormat.getLocaleInstance().alias(METER.multiply(0.3048), "foot"); UnitFormat.getLocaleInstance().alias(METER.multiply(0.3048), "feet"); UnitFormat.getLocaleInstance().alias(METER, "meter"); UnitFormat.getLocaleInstance().alias(METER, "metre"); [/code] If the specified label is already associated to an unit the previous association is discarded or ignored.
        Specified by:
        alias in class UnitFormat
        Parameters:
        unit - the unit being aliased.
        alias - the alias attached to this unit.
      • isValidIdentifier

        public boolean isValidIdentifier​(String name)
        Description copied from class: UnitFormat
        Indicates if the specified name can be used as unit identifier.
        Specified by:
        isValidIdentifier in class UnitFormat
        Parameters:
        name - the identifier to be tested.
        Returns:
        true if the name specified can be used as label or alias for this format;false otherwise.
      • nameFor

        public String nameFor​(Unit<?> unit)
      • unitFor

        public Unit<?> unitFor​(String name)