Class IntervalFormatting


  • public class IntervalFormatting
    extends Object
    Describes the formatting of a string representing TemporalAmounts such as Duration and Period. Primarily, this provides the formatting pattern used for laying out the various fields. Since there is much less variation in the possible display a simpler syntax is used than in other temporal formats. The format is denoted with a pattern string composed of various characters representing the amounts combined with optional literal characters. The characters that will be parsed representing the various units are as follows. Y - Years M - Months D - Days H - Hours m - Minutes s - Seconds n - Nanoseconds Since intervals are represented as a collection of numeric values a single letter represents each quantity. Any of these may optionally be used as a literal character by escaping the character with a \. If any other characters are used in the format they are assumed to be literals and will be parsed as such. It is best to delimit each unit with a whitespace or literal to prevent parsing issues.
    • Constructor Detail

      • IntervalFormatting

        public IntervalFormatting​(String pattern)
        Defines a format using the specified pattern.
        Parameters:
        pattern - the text format to use
    • Method Detail

      • setPattern

        public void setPattern​(String pattern)
        Specifies the format pattern to use when parsing or formatting interval values such as Duration and Period.
        Parameters:
        pattern - the format pattern to use
      • getPattern

        public String getPattern()
        Gets the format pattern used for parsing and formatting interval values such as Duration and Period.
        Returns:
        the format pattern to use