Class SimpleInterval.Factory<T>

java.lang.Object
net.time4j.range.SimpleInterval.Factory<T>
Type Parameters:
T - generic type of timepoints on the underlying timeline
Enclosing class:
SimpleInterval<T>

public static class SimpleInterval.Factory<T> extends Object

Serves for the creation of generic simple intervals on a timeline.

  • Method Details

    • between

      public SimpleInterval<T> between(T start, T end)

      Creates a new interval between given boundaries.

      Parameters:
      start - the start of interval (always inclusive)
      end - the end of interval (inclusive if calendrical else exclusive)
      Returns:
      new interval (closed if calendrical else half-open)
    • since

      public SimpleInterval<T> since(T start)

      Creates a new interval since given start.

      Parameters:
      start - the start of interval (inclusive)
      Returns:
      new interval (half-open and infinite)
    • until

      public SimpleInterval<T> until(T end)

      Creates a new interval until given end.

      Parameters:
      end - the end of interval (inclusive if calendrical else exclusive)
      Returns:
      new infinite interval
    • parse

      public SimpleInterval<T> parse(CharSequence text, ChronoParser<T> parser) throws ParseException

      Interpretes given text as interval using a localized interval pattern.

      If given parser does not contain a reference to a locale then the interval pattern "{0}/{1}" will be used.

      Parameters:
      text - text to be parsed
      parser - format object for parsing start and end components
      Returns:
      parsed interval (closed if calendrical else half-open)
      Throws:
      IndexOutOfBoundsException - if given text is empty
      ParseException - if the text is not parseable
      See Also:
      parse(CharSequence, ChronoParser, String)
    • parse

      public SimpleInterval<T> parse(CharSequence text, ChronoParser<T> parser, String intervalPattern) throws ParseException

      Interpretes given text as interval using given interval pattern.

      For version v4.21 or later, it is also possible to use an or-pattern logic. Example see DateInterval.parse(String, ChronoParser, String).

      Parameters:
      text - text to be parsed
      parser - format object for parsing start and end components
      intervalPattern - interval pattern containing placeholders {0} and {1} (for start and end)
      Returns:
      parsed interval (closed if calendrical else half-open)
      Throws:
      IndexOutOfBoundsException - if given text is empty
      ParseException - if the text is not parseable