Enum Class EpochDays

java.lang.Object
java.lang.Enum<EpochDays>
net.time4j.engine.EpochDays
All Implemented Interfaces:
Serializable, Comparable<EpochDays>, java.lang.constant.Constable, Comparator<ChronoDisplay>, ChronoElement<Long>

public enum EpochDays extends Enum<EpochDays> implements ChronoElement<Long>

Defines elements based on different epoch-related day numbers.

Some day number procedures really use decimal fractions in order to represent wall time fractions in calendar dates (for example julian days). This enum only supports pure date types of type Calendrical and always uses the largest integer which is still smaller than or equal to the decimal fraction in question (mathematically a floor()-function.

Instances of this element class will be automatically registered in any chronology which is compatible to Calendrical.

Author:
Meno Hochschild
See Also:
Calendrical
  • Enum Constant Details

    • UTC

      public static final EpochDays UTC

      Reference point is the introduction of UTC on date [1972-01-01] at midnight as day zero.

    • UNIX

      public static final EpochDays UNIX

      Reference point is the first of January 1970 at midnight as day zero.

      Example:

        import static net.time4j.Month.FEBRUARY;
      
        PlainDate date = PlainDate.of(1970, FEBRUARY, 4);
        System.out.println(date.get(EpochDays.UNIX)); // output: 34
       

      Strictly spoken, the UNIX time is counted in seconds. This element counts in days based on the relation "1 day = 86400 seconds".

    • MODIFIED_JULIAN_DATE

      @FormattableElement(format="g") public static final EpochDays MODIFIED_JULIAN_DATE

      Count of days relative to the ISO-date [1858-11-17] as day zero.

      Used by astronomers for example.

    • EXCEL

      public static final EpochDays EXCEL

      Count of days relative to the ISO-date [1900-01-01] as day 1.

      Used by MS-Excel in Windows operating systems.

    • ANSI

      public static final EpochDays ANSI

      Count of days relative to the ISO-date [1601-01-01] as day 1.

      Used by COBOL for example.

    • RATA_DIE

      public static final EpochDays RATA_DIE

      Count of days relative to the ISO-date [0001-01-01] as day 1.

      Used by the autors Nachum Dershowitz and Edward M. Reingold in their standard work "CalendarDate Calculations".

    • JULIAN_DAY_NUMBER

      public static final EpochDays JULIAN_DAY_NUMBER

      Count of julian days relative to the the julian calendar date [1st of January 4713 BC] at noon [12:00] as day zero.

      The julian epoch date corresponds to the proleptic ISO-date [-4713-11-24]. The ISO-day centered around noon will be taken into account whose associated julian day starts at noon.

    • LILIAN_DAY_NUMBER

      public static final EpochDays LILIAN_DAY_NUMBER

      Count of days relative to gregorian cut-over date [1582-10-15] as day 1.

  • Method Details

    • values

      public static EpochDays[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static EpochDays valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • transform

      public long transform(long amount, EpochDays epoch)

      Converts given day number to a day number based on this epoch at reference time of midnight.

      Parameters:
      amount - count of days relative to given epoch at noon
      epoch - epoch reference
      Returns:
      count of days relative to this epoch
      Throws:
      IllegalArgumentException - if the first argument is out of range
    • getType

      public Class<Long> getType()
      Description copied from interface: ChronoElement

      Yields the reified value type.

      Specified by:
      getType in interface ChronoElement<Long>
      Returns:
      type of associated values
    • getSymbol

      public char getSymbol()

      Defines the format symbol.

      Specified by:
      getSymbol in interface ChronoElement<Long>
      Returns:
      "g" if MODIFIED_JULIAN_DATE else ASCII-0
      See Also:
      FormattableElement
    • compare

      public int compare(ChronoDisplay o1, ChronoDisplay o2)
      Description copied from interface: ChronoElement

      Applies an element-orientated sorting of any chronological entities.

      The value type V is usually a subtype of the interface Comparable so that this method will usually be based on the expression o1.get(this).compareTo(o2.get(this)). In other words, this method compares the element values of given chronological entities. It is even permitted to compare entities of different chronological types as long as the entities both support this element.

      It should be noted however that a element value comparison does often not induce any temporal (complete) order. Counter examples are the year of gregorian BC-era (reversed temporal order before Jesu birth) or the clock display of hours (12 is indeed the begin at midnight).

      Specified by:
      compare in interface ChronoElement<Long>
      Specified by:
      compare in interface Comparator<ChronoDisplay>
      Parameters:
      o1 - the first object to be compared
      o2 - the second object to be compared
      Returns:
      a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second
    • getDefaultMinimum

      public Long getDefaultMinimum()
      Description copied from interface: ChronoElement

      Returns the default minimum of this element which is not dependent on the chronological context.

      Note: This minimum does not necessarily define a minimum for all possible circumstances but only the default minimum under normal conditions such that the default minimum always exists and can be used as prototypical value. An example is the start of day which is usually midnight in ISO-8601 and can only deviate in specialized timezone context.

      Specified by:
      getDefaultMinimum in interface ChronoElement<Long>
      Returns:
      default minimum value of element
      See Also:
      ChronoElement.getDefaultMaximum()
    • getDefaultMaximum

      public Long getDefaultMaximum()
      Description copied from interface: ChronoElement

      Returns the default maximum of this element which is not dependent on the chronological context.

      Note: This maximum does not necessarily define a maximum for all possible circumstances but only the default maximum under normal conditions. An example is the second of minute whose default maximum is 59 while the largest maximum can be 60 in context of UTC-leapseconds.

      Specified by:
      getDefaultMaximum in interface ChronoElement<Long>
      Returns:
      default maximum value of element
      See Also:
      ChronoElement.getDefaultMinimum()
    • isDateElement

      public boolean isDateElement()

      This element is a date element.

      Specified by:
      isDateElement in interface ChronoElement<Long>
      Returns:
      true
      See Also:
      ChronoElement.isTimeElement()
    • isTimeElement

      public boolean isTimeElement()

      This element is no wall time element.

      Specified by:
      isTimeElement in interface ChronoElement<Long>
      Returns:
      false
      See Also:
      ChronoElement.isDateElement()
    • isLenient

      public boolean isLenient()
      Description copied from interface: ChronoElement

      Queries if setting of element values is performed in a lenient way.

      Specified by:
      isLenient in interface ChronoElement<Long>
      Returns:
      true if lenient else false (standard)
      See Also:
      ElementRule.withValue(T, V, boolean)