Interface UnitSuffixProvider


  • public interface UnitSuffixProvider
    A provider of unit suffixes for formatting Duration values of varying units.

    Example: Formatting a Duration of 243 minutes in units of hours and minutes requires a unit suffix for 4 (hours) and a unit suffix for 3 (minutes). If the desired formatted duration string is "4hrs 3mins" then the UnitSuffixProvider will provide the "hrs" and "mins" unit suffixes.

    • Method Detail

      • suffixFor

        String suffixFor​(ChronoUnit unit,
                         BigDecimal magnitude)
        Get the appropriate suffix to use for the specified unit and magnitude.

        This method will only be called if the magnitude cannot be represented as an int. Otherwise, the suffixFor(ChronoUnit, int) method will be used.

        Parameters:
        unit - The unit of the value being formatted.
        magnitude - The value being formatted.
        Returns:
        The String suffix to use for a time value with this unit and magnitude.
      • suffixFor

        String suffixFor​(ChronoUnit unit,
                         int magnitude)
        Get the appropriate suffix to use for the specified unit and magnitude.

        This method will only be called if the magnitude can accurately be represented as an int. Otherwise, the suffixFor(ChronoUnit, BigDecimal) method will be used.

        Parameters:
        unit - The unit of the value being formatted.
        magnitude - The value being formatted.
        Returns:
        The String suffix to use for a time value with this unit and magnitude.