Class Months

All Implemented Interfaces:
Serializable, Comparable<Months>, TimeSpan<CalendarUnit>

public final class Months extends SingleUnitTimeSpan<CalendarUnit,​Months>

Represents a time span in gregorian months.

Since:
3.21/4.17
Author:
Meno Hochschild
See Also:
Serialized Form
  • Field Details

    • ZERO

      public static final Months ZERO

      Constant for zero gregorian months.

    • ONE

      public static final Months ONE

      Constant for exactly one gregorian month.

  • Method Details

    • of

      public static Months of(int months)

      Obtains a time span in given gregorian months.

      Parameters:
      months - count of gregorian months, maybe negative
      Returns:
      time span in months
      See Also:
      CalendarUnit.MONTHS
    • between

      public static <T extends TimePoint<? super CalendarUnit,​ T>> Months between(T t1, T t2)

      Determines the temporal distance between given dates/time-points in gregorian months.

      Type Parameters:
      T - generic type of time-points
      Parameters:
      t1 - first time-point
      t2 - second time-point
      Returns:
      result of month difference
      See Also:
      PlainDate, PlainTimestamp
    • between

      public static Months between(CalendarMonth m1, CalendarMonth m2)

      Determines the difference in months between given calendar months.

      Parameters:
      m1 - first calendar month
      m2 - second calendar month
      Returns:
      month difference
    • parsePeriod

      public static Months parsePeriod(String period) throws ParseException

      Parses the canonical ISO-8601-format "PnM" with possible preceding minus-char.

      Parameters:
      period - the formatted string to be parsed
      Returns:
      parsed instance
      Throws:
      ParseException - if given argument cannot be parsed