Class Grego


  • public class Grego
    extends java.lang.Object
    A utility class providing proleptic Gregorian calendar functions used by time zone and calendar code. Do not instantiate. Note: Unlike GregorianCalendar, all computations performed by this class occur in the pure proleptic GregorianCalendar.
    • Constructor Summary

      Constructors 
      Constructor Description
      Grego()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int dayOfWeek​(long day)
      Return the day of week on the 1970-epoch day
      static int[] dayToFields​(long day, int[] fields)  
      static long fieldsToDay​(int year, int month, int dom)
      Convert a year, month, and day-of-month, given in the proleptic Gregorian calendar, to 1970 epoch days.
      static long floorDivide​(long numerator, long denominator)  
      private static long floorDivide​(long numerator, long denominator, long[] remainder)  
      static int getDayOfWeekInMonth​(int year, int month, int dayOfMonth)  
      static boolean isLeapYear​(int year)
      Return true if the given year is a leap year.
      static int monthLength​(int year, int month)
      Return the number of days in the given month.
      static int previousMonthLength​(int year, int month)
      Return the length of a previous month of the Gregorian calendar.
      static int[] timeToFields​(long time, int[] fields)  
      static java.lang.String timeToString​(long time)
      Convenient method for formatting time to ISO 8601 style date string.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Grego

        public Grego()
    • Method Detail

      • isLeapYear

        public static final boolean isLeapYear​(int year)
        Return true if the given year is a leap year.
        Parameters:
        year - Gregorian year, with 0 == 1 BCE, -1 == 2 BCE, etc.
        Returns:
        true if the year is a leap year
      • monthLength

        public static final int monthLength​(int year,
                                            int month)
        Return the number of days in the given month.
        Parameters:
        year - Gregorian year, with 0 == 1 BCE, -1 == 2 BCE, etc.
        month - 0-based month, with 0==Jan
        Returns:
        the number of days in the given month
      • previousMonthLength

        public static final int previousMonthLength​(int year,
                                                    int month)
        Return the length of a previous month of the Gregorian calendar.
        Parameters:
        year - Gregorian year, with 0 == 1 BCE, -1 == 2 BCE, etc.
        month - 0-based month, with 0==Jan
        Returns:
        the number of days in the month previous to the given month
      • fieldsToDay

        public static long fieldsToDay​(int year,
                                       int month,
                                       int dom)
        Convert a year, month, and day-of-month, given in the proleptic Gregorian calendar, to 1970 epoch days.
        Parameters:
        year - Gregorian year, with 0 == 1 BCE, -1 == 2 BCE, etc.
        month - 0-based month, with 0==Jan
        dom - 1-based day of month
        Returns:
        the day number, with day 0 == Jan 1 1970
      • dayOfWeek

        public static int dayOfWeek​(long day)
        Return the day of week on the 1970-epoch day
        Parameters:
        day - the 1970-epoch day (integral value)
        Returns:
        the day of week
      • dayToFields

        public static int[] dayToFields​(long day,
                                        int[] fields)
      • timeToFields

        public static int[] timeToFields​(long time,
                                         int[] fields)
      • floorDivide

        public static long floorDivide​(long numerator,
                                       long denominator)
      • floorDivide

        private static long floorDivide​(long numerator,
                                        long denominator,
                                        long[] remainder)
      • getDayOfWeekInMonth

        public static int getDayOfWeekInMonth​(int year,
                                              int month,
                                              int dayOfMonth)
      • timeToString

        public static java.lang.String timeToString​(long time)
        Convenient method for formatting time to ISO 8601 style date string.
        Parameters:
        time - long time
        Returns:
        ISO-8601 date string