Package com.ibm.icu.impl
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 Summary
Fields Modifier and Type Field Description static longMAX_MILLISstatic intMILLIS_PER_DAYstatic intMILLIS_PER_HOURstatic intMILLIS_PER_MINUTEstatic intMILLIS_PER_SECONDstatic longMIN_MILLIS
-
Constructor Summary
Constructors Constructor Description Grego()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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)static intgetDayOfWeekInMonth(int year, int month, int dayOfMonth)static booleanisLeapYear(int year)Return true if the given year is a leap year.static intmonthLength(int year, int month)Return the number of days in the given month.static 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 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
-
-
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)
-
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
-
-