Class DateUtils

java.lang.Object
org.apache.orc.impl.DateUtils

public class DateUtils extends Object
Conversion utilities from the hybrid Julian/Gregorian calendar to/from the proleptic Gregorian.

The semantics here are to hold the string representation constant and change the epoch offset rather than holding the instant in time constant and change the string representation.

These utilities will be fast for the common case (> 1582 AD), but slow for old dates.

  • Method Details

    • convertDateToProleptic

      public static int convertDateToProleptic(int hybrid)
      Convert an epoch day from the hybrid Julian/Gregorian calendar to the proleptic Gregorian.
      Parameters:
      hybrid - day of epoch in the hybrid Julian/Gregorian
      Returns:
      day of epoch in the proleptic Gregorian
    • convertDateToHybrid

      public static int convertDateToHybrid(int proleptic)
      Convert an epoch day from the proleptic Gregorian calendar to the hybrid Julian/Gregorian.
      Parameters:
      proleptic - day of epoch in the proleptic Gregorian
      Returns:
      day of epoch in the hybrid Julian/Gregorian
    • convertTimeToProleptic

      public static long convertTimeToProleptic(long hybrid, boolean useUtc)
      Convert epoch millis from the hybrid Julian/Gregorian calendar to the proleptic Gregorian.
      Parameters:
      hybrid - millis of epoch in the hybrid Julian/Gregorian
      useUtc - use UTC instead of local
      Returns:
      millis of epoch in the proleptic Gregorian
    • convertTimeToHybrid

      public static long convertTimeToHybrid(long proleptic, boolean useUtc)
      Convert epoch millis from the proleptic Gregorian calendar to the hybrid Julian/Gregorian.
      Parameters:
      proleptic - millis of epoch in the proleptic Gregorian
      useUtc - use UTC instead of local
      Returns:
      millis of epoch in the hybrid Julian/Gregorian
    • convertDate

      public static int convertDate(int original, boolean fromProleptic, boolean toProleptic)
    • convertTime

      public static long convertTime(long original, boolean fromProleptic, boolean toProleptic, boolean useUtc)
    • parseDate

      public static Integer parseDate(String date, boolean fromProleptic)
    • printDate

      public static String printDate(int date, boolean fromProleptic)
    • getTimeFormat

      public static DateTimeFormatter getTimeFormat(boolean useProleptic, boolean useUtc)
    • parseTime

      public static Long parseTime(String date, boolean fromProleptic, boolean useUtc)
    • printTime

      public static String printTime(long millis, boolean fromProleptic, boolean useUtc)