Class Grego

java.lang.Object
com.ibm.icu.impl.Grego

public class Grego extends 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.
  • Field Details

  • Constructor Details

    • Grego

      public Grego()
  • Method Details

    • 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
    • dayToYear

      public static Pair<Integer,Integer> dayToYear(long day)
    • dayToFields

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

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

      public static int timeToYear(long time)
    • floorDivide

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

      private static Pair<Long,Integer> floorDivideAndRemainer(long numerator, int denominator)
    • getDayOfWeekInMonth

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

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