Package net.time4j

Class Weekcycle

All Implemented Interfaces:
Serializable, ChronoUnit, IsoDateUnit, IsoUnit

public final class Weekcycle extends BasicUnit implements IsoDateUnit, Serializable

Represents a special unit for week-based years which are described by ISO-8601 and follow the week cycle from Monday to Sunday.

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

    Fields
    Modifier and Type
    Field
    Description
    static Weekcycle
    Constant for week-based years which either have 364 or 371 days.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    between​(PlainDate start, PlainDate end)
    Calculates the temporal distance between given calendar dates in this calendar unit.
    double
    Defines the typical length of this time unit in seconds without taking into account anomalies like timezone effects or leap seconds.
    char
    Gets the format symbol which is used to display this time unit in canonical representations of timespans.
    boolean
    Queries if this time unit is calendrical respective is at least as long as a calendar day.
     

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • YEARS

      public static final Weekcycle YEARS

      Constant for week-based years which either have 364 or 371 days.

  • Method Details

    • between

      public long between(PlainDate start, PlainDate end)

      Calculates the temporal distance between given calendar dates in this calendar unit.

      Parameters:
      start - starting date
      end - ending date
      Returns:
      duration as count of this unit
    • getSymbol

      public char getSymbol()
      Description copied from interface: IsoUnit

      Gets the format symbol which is used to display this time unit in canonical representations of timespans.

      Canonical timespan formats follow ISO-8601. For example, the day unit is represented by the symbol D. Note that the letters P and T must not be used because these special characters are for structuring, the display. In ISO-8601 following symbols are defined:

      • Y - year
      • M - month or minute
      • W - week
      • D - day
      • H - hour
      • S - second
      • P - qualifies a timespan (period)
      • T - separates date and time part

      If this method yields as special case a digit 1-9 then Time4J expects a fractional display of preceding second unit S that is nanoseconds, microseconds and milliseconds. Time4J will use the comma as decimal separation char in the canonical display as recommended by ISO-8601 unless the system property "net.time4j.format.iso.decimal.dot" is set to true (which causes the usage of a dot).

      Specified by:
      getSymbol in interface IsoUnit
      Returns:
      char (ASCII-NULL if undefined)
      See Also:
      Duration.toString()
    • getLength

      public double getLength()
      Description copied from interface: ChronoUnit

      Defines the typical length of this time unit in seconds without taking into account anomalies like timezone effects or leap seconds.

      Important note: This method can only yield an estimated value and is not intended to assist in calculations of durations, but only in sorting of units.

      Specified by:
      getLength in interface ChronoUnit
      Returns:
      estimated decimal value in seconds
    • isCalendrical

      public boolean isCalendrical()
      Description copied from interface: ChronoUnit

      Queries if this time unit is calendrical respective is at least as long as a calendar day.

      Implementation note: The method must be consistent with the typical length of the unit. The expression Double.compare(unit.getLength(), 86400.0) >= 0 is equivalent to unit.isCalendrical().

      Specified by:
      isCalendrical in interface ChronoUnit
      Returns:
      true if at least as long as a day else false
    • toString

      public String toString()
      Overrides:
      toString in class Object