Class CalendarDays

java.lang.Object
net.time4j.engine.CalendarDays
All Implemented Interfaces:
Serializable, Comparable<CalendarDays>

public final class CalendarDays extends Object implements Comparable<CalendarDays>, Serializable

Represents a count of calendar days.

Since:
3.4/4.3
Author:
Meno Hochschild
See Also:
Calendrical.plus(CalendarDays), Calendrical.minus(CalendarDays), CalendarVariant.plus(CalendarDays), CalendarVariant.minus(CalendarDays), Serialized Form
  • Field Details

    • ZERO

      public static final CalendarDays ZERO
      Represents zero calendar days.
    • ONE

      public static final CalendarDays ONE
      Represents exactly one calendar day.
  • Method Details

    • of

      public static CalendarDays of(long days)

      Wraps given count of calendar days.

      Parameters:
      days - count of calendar days
      Returns:
      new or cached instance of CalendarDays
      Since:
      3.4/4.3
    • getAmount

      public long getAmount()

      Yields the calendar days as primitive.

      Returns:
      count of calendar days, maybe zero or negative
      Since:
      3.4/4.3
    • isZero

      public boolean isZero()

      Is the count of calendar days equal to zero?

      Returns:
      boolean
      Since:
      3.4/4.3
    • isNegative

      public boolean isNegative()

      Is the count of calendar days smaller than zero?

      Returns:
      boolean
      Since:
      3.4/4.3
    • between

      public static CalendarDays between(CalendarDate start, CalendarDate end)

      Calculates the delta of calendar days between given calendar dates.

      Parameters:
      start - first calendar date (inclusive)
      end - second calendar date (exclusive)
      Returns:
      count of calendar days between start and end
      Since:
      3.8/4.5
    • abs

      public CalendarDays abs()

      Yields the absolute value of the represented calendar days.

      Returns:
      non-negative count of calendar days
      Since:
      3.4/4.3
    • inverse

      public CalendarDays inverse()

      Negates this duration if not zero.

      Returns:
      inversed count of calendar days
      Since:
      5.0
    • plus

      public CalendarDays plus(CalendarDays other)

      Yields the sum of the represented calendar days of this instance and given argument.

      Parameters:
      other - calendar days to be added
      Returns:
      sum of calendar days
      Since:
      3.4/4.3
    • minus

      public CalendarDays minus(CalendarDays other)

      Yields the delta of the represented calendar days of this instance and given argument.

      Parameters:
      other - calendar days to be subtracted
      Returns:
      delta of calendar days
      Since:
      3.4/4.3
    • compareTo

      public int compareTo(CalendarDays other)
      Specified by:
      compareTo in interface Comparable<CalendarDays>
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()

      Returns an ISO-8601-like duration representation in format "[-]P{n}D".

      Overrides:
      toString in class Object
      Returns:
      String