Class InstantPatternDynamicFormatter.DynamicPatternSequence

    • Constructor Detail

      • DynamicPatternSequence

        DynamicPatternSequence​(java.lang.String singlePattern)
        Parameters:
        singlePattern - A DateTimeFormatter pattern containing a single letter.
      • DynamicPatternSequence

        DynamicPatternSequence​(java.lang.String pattern,
                               java.time.temporal.ChronoUnit precision)
        Parameters:
        pattern - Any DateTimeFormatter pattern.
        precision - The maximum interval of time over which this pattern is constant.
    • Method Detail

      • tryMerge

        @Nullable InstantPatternDynamicFormatter.PatternSequence tryMerge​(InstantPatternDynamicFormatter.PatternSequence other,
                                                                          java.time.temporal.ChronoUnit thresholdPrecision)
        Description copied from class: InstantPatternDynamicFormatter.PatternSequence
        Tries to merge two pattern sequences.

        If not {@link null}, the pattern sequence returned by this method must:

        1. Have a InstantPatternDynamicFormatter.PatternSequence.precision, which is the minimum of the precisions of the two merged sequences.
        2. Create formatters that are equivalent to the concatenation of the formatters produced by the two merged sequences.

        The returned pattern sequence should try to achieve these two goals:

        1. Create formatters which are faster than the concatenation of the formatters produced by the two merged sequences.
        2. It should be {@link null} if one of the pattern sequences is effectively constant over thresholdPrecision, but the other one is not.
        Specified by:
        tryMerge in class InstantPatternDynamicFormatter.PatternSequence
        Parameters:
        other - A pattern sequence.
        thresholdPrecision - A precision threshold to determine effectively constant sequences. This prevents merging effectively constant and dynamic pattern sequences.
        Returns:
        A merged formatter factory or null if merging is not possible.
      • patternPrecision

        private static java.time.temporal.ChronoUnit patternPrecision​(java.lang.String singlePattern)
        Parameters:
        singlePattern - a single-letter directive singlePattern complying (e.g., H, HH, or pHH)
        Returns:
        the time precision of the directive
      • validateContent

        private static void validateContent​(java.lang.String content)
      • removePadding

        private static java.lang.String removePadding​(java.lang.String content)