Package com.ibm.icu.impl
Class Grego
- java.lang.Object
-
- com.ibm.icu.impl.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.
-
-
Field Summary
Fields Modifier and Type Field Description private static int[]
DAYS_BEFORE
private static int
JULIAN_1_CE
private static int
JULIAN_1970_CE
static long
MAX_MILLIS
static int
MILLIS_PER_DAY
static int
MILLIS_PER_HOUR
static int
MILLIS_PER_MINUTE
static int
MILLIS_PER_SECOND
static long
MIN_MILLIS
private static int[]
MONTH_LENGTH
-
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 daystatic 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.
-
-
-
Field Detail
-
MIN_MILLIS
public static final long MIN_MILLIS
- See Also:
- Constant Field Values
-
MAX_MILLIS
public static final long MAX_MILLIS
- See Also:
- Constant Field Values
-
MILLIS_PER_SECOND
public static final int MILLIS_PER_SECOND
- See Also:
- Constant Field Values
-
MILLIS_PER_MINUTE
public static final int MILLIS_PER_MINUTE
- See Also:
- Constant Field Values
-
MILLIS_PER_HOUR
public static final int MILLIS_PER_HOUR
- See Also:
- Constant Field Values
-
MILLIS_PER_DAY
public static final int MILLIS_PER_DAY
- See Also:
- Constant Field Values
-
JULIAN_1_CE
private static final int JULIAN_1_CE
- See Also:
- Constant Field Values
-
JULIAN_1970_CE
private static final int JULIAN_1970_CE
- See Also:
- Constant Field Values
-
MONTH_LENGTH
private static final int[] MONTH_LENGTH
-
DAYS_BEFORE
private static final int[] DAYS_BEFORE
-
-
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==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
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
-
-