Package com.ibm.icu.impl
Class Grego
java.lang.Object
com.ibm.icu.impl.Grego
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 Summary
FieldsModifier and TypeFieldDescriptionprivate static final int[]private static final intprivate static final intstatic final longstatic final intstatic final intstatic final intstatic final intstatic final longprivate static final int[] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intdayOfWeek(long day) Return the day of week on the 1970-epoch daystatic int[]dayToFields(long day, int[] fields) static longfieldsToDay(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 longfloorDivide(long numerator, long denominator) private static longfloorDivide(long numerator, long denominator, long[] remainder) static intgetDayOfWeekInMonth(int year, int month, int dayOfMonth) static final booleanisLeapYear(int year) Return true if the given year is a leap year.static final intmonthLength(int year, int month) Return the number of days in the given month.static final intpreviousMonthLength(int year, int month) Return the length of a previous month of the Gregorian calendar.static int[]timeToFields(long time, int[] fields) static StringtimeToString(long time) Convenient method for formatting time to ISO 8601 style date string.
-
Field Details
-
MIN_MILLIS
public static final long MIN_MILLIS- See Also:
-
MAX_MILLIS
public static final long MAX_MILLIS- See Also:
-
MILLIS_PER_SECOND
public static final int MILLIS_PER_SECOND- See Also:
-
MILLIS_PER_MINUTE
public static final int MILLIS_PER_MINUTE- See Also:
-
MILLIS_PER_HOUR
public static final int MILLIS_PER_HOUR- See Also:
-
MILLIS_PER_DAY
public static final int MILLIS_PER_DAY- See Also:
-
JULIAN_1_CE
private static final int JULIAN_1_CE- See Also:
-
JULIAN_1970_CE
private static final int JULIAN_1970_CE- See Also:
-
MONTH_LENGTH
private static final int[] MONTH_LENGTH -
DAYS_BEFORE
private static final int[] DAYS_BEFORE
-
-
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==Jandom- 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
Convenient method for formatting time to ISO 8601 style date string.- Parameters:
time- long time- Returns:
- ISO-8601 date string
-