Class AmountFormats


  • public final class AmountFormats
    extends java.lang.Object
    Provides the ability to format a temporal amount.

    This allows a TemporalAmount, such as Duration or Period, to be formatted. Only selected formatting options are provided.

    Implementation Requirements:

    This class is immutable and thread-safe.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String iso8601​(java.time.Period period, java.time.Duration duration)
      Formats a period and duration to a string in ISO-8601 format.
      static java.lang.String wordBased​(java.time.Duration duration, java.util.Locale locale)
      Formats a duration to a string in a localized word-based format.
      static java.lang.String wordBased​(java.time.Period period, java.time.Duration duration, java.util.Locale locale)
      Formats a period and duration to a string in a localized word-based format.
      static java.lang.String wordBased​(java.time.Period period, java.util.Locale locale)
      Formats a period to a string in a localized word-based format.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • iso8601

        public static java.lang.String iso8601​(java.time.Period period,
                                               java.time.Duration duration)
        Formats a period and duration to a string in ISO-8601 format.

        To obtain the ISO-8601 format of a Period or Duration individually, simply call toString(). See also PeriodDuration.

        Parameters:
        period - the period to format
        duration - the duration to format
        Returns:
        the ISO-8601 format for the period and duration
      • wordBased

        public static java.lang.String wordBased​(java.time.Period period,
                                                 java.util.Locale locale)
        Formats a period to a string in a localized word-based format.

        This returns a word-based format for the period. The words are configured in a resource bundle text file - org.threeten.extra.wordbased.properties - with overrides per language.

        Parameters:
        period - the period to format
        locale - the locale to use
        Returns:
        the localized word-based format for the period
      • wordBased

        public static java.lang.String wordBased​(java.time.Duration duration,
                                                 java.util.Locale locale)
        Formats a duration to a string in a localized word-based format.

        This returns a word-based format for the duration. The words are configured in a resource bundle text file - org.threeten.extra.wordbased.properties - with overrides per language.

        Parameters:
        duration - the duration to format
        locale - the locale to use
        Returns:
        the localized word-based format for the duration
      • wordBased

        public static java.lang.String wordBased​(java.time.Period period,
                                                 java.time.Duration duration,
                                                 java.util.Locale locale)
        Formats a period and duration to a string in a localized word-based format.

        This returns a word-based format for the period. The words are configured in a resource bundle text file - org.threeten.extra.wordbased.properties - with overrides per language.

        Parameters:
        period - the period to format
        duration - the duration to format
        locale - the locale to use
        Returns:
        the localized word-based format for the period and duration