@Scriptable public final class CalendarUtil extends Object
Modifier and Type | Method and Description |
---|---|
static Date |
getAscensionDate(Date p_dt,
TimeZone p_tz) |
static Date |
getAscensionDate(int p_iYear,
TimeZone p_tz) |
static long |
getAscensionDateInMillis(int p_iYear,
TimeZone p_tz) |
static Date |
getAshWednesdayDate(Date p_dt,
TimeZone p_tz) |
static Date |
getAshWednesdayDate(int p_iYear,
TimeZone p_tz) |
static long |
getAshWednesdayDateInMillis(int p_iYear,
TimeZone p_tz) |
static Date |
getCorpusChristiDate(Date p_dt,
TimeZone p_tz) |
static Date |
getCorpusChristiDate(int p_iYear,
TimeZone p_tz) |
static long |
getCorpusChristiDateInMillis(int p_iYear,
TimeZone p_tz) |
static Date |
getEasterDate(Date p_dt,
TimeZone p_tz) |
static Date |
getEasterDate(int p_iYear,
TimeZone p_tz) |
static long |
getEasterDateInMillis(int p_iYear,
TimeZone p_tz) |
static Date |
getEasterMondayDate(Date p_dt,
TimeZone p_tz) |
static Date |
getEasterMondayDate(int p_iYear,
TimeZone p_tz) |
static long |
getEasterMondayDateInMillis(int p_iYear,
TimeZone p_tz) |
static Date |
getGoodFridayDate(Date p_dt,
TimeZone p_tz) |
static Date |
getGoodFridayDate(int p_iYear,
TimeZone p_tz) |
static long |
getGoodFridayDateInMillis(int p_iYear,
TimeZone p_tz) |
static int |
getISO8601WeekNumber(Date p_dt,
TimeZone p_tz)
Get the week number as defined in DIN 1355/ISO 8601.
|
static int |
getISO8601WeekNumber(int p_iYear,
int p_iMonth,
int p_iDay)
Get the week number as defined in DIN 1355/ISO 8601.
|
static int |
getISO8601WeekStartOffset(int p_iYear,
int p_iWeek)
Get the offset in days of the first day of the given week, calculated
from first of January of the given year.
|
static long |
getLunationNumber(Date p_dt)
Get the Brown Lunation Number.
|
static long |
getLunationNumber(long p_lTime)
Get the Brown Lunation Number.
|
static Date |
getMaundyThursdayDate(Date p_dt,
TimeZone p_tz) |
static Date |
getMaundyThursdayDate(int p_iYear,
TimeZone p_tz) |
static long |
getMaundyThursdayDateInMillis(int p_iYear,
TimeZone p_tz) |
static long |
getMeeusLunationNumber(Date p_dt)
Get the Meeus Lunation Number.
|
static long |
getMeeusLunationNumber(long p_lTime)
Get the Meeus Lunation Number.
|
static long |
getNumberOfMidnightsBetween(Date p_dt1,
Date p_dt2,
TimeZone p_tz)
Get the number of midnights between two dates in the give time zone.
|
static Date |
getPenanceDayDate(Date p_dt,
TimeZone p_tz) |
static Date |
getPenanceDayDate(int p_iYear,
TimeZone p_tz) |
static long |
getPenanceDayDateInMillis(int p_iYear,
TimeZone p_tz) |
static Date |
getPentecostDate(Date p_dt,
TimeZone p_tz) |
static Date |
getPentecostDate(int p_iYear,
TimeZone p_tz)
Same as
getWhitSundayDate(int, TimeZone) . |
static long |
getPentecostDateInMillis(int p_iYear,
TimeZone p_tz)
Same as
getWhitSundayDate(int, TimeZone) . |
static double |
getPhaseOfTheMoon(Date p_dt)
Get the phase of the moon.
|
static double |
getPhaseOfTheMoon(long p_lTime)
Get the phase of the moon.
|
static int |
getQuarter(Date p_dt,
TimeZone p_tz)
Get the quarter that contains the given date.
|
static Date |
getShroveMondayDate(Date p_dt,
TimeZone p_tz) |
static Date |
getShroveMondayDate(int p_iYear,
TimeZone p_tz) |
static long |
getShroveMondayDateInMillis(int p_iYear,
TimeZone p_tz) |
static Date |
getStartOfQuarter(Date p_dt,
TimeZone p_tz)
Get the start of the quarter that contains the given date.
|
static long |
getStartOfQuarterInMillis(Date p_dt,
TimeZone p_tz)
Get the start of the quarter that contains the given date.
|
static Date |
getStartOfWeek(Date p_dt,
int p_iFirstDayOfWeek,
TimeZone p_tz)
Get the start of the week that contains the given date.
|
static long |
getStartOfWeekInMillis(Date p_dt,
int p_iFirstDayOfWeek,
TimeZone p_tz)
Get the start of the week that contains the given date.
|
static Date |
getWhitMondayDate(Date p_dt,
TimeZone p_tz) |
static Date |
getWhitMondayDate(int p_iYear,
TimeZone p_tz) |
static long |
getWhitMondayDateInMillis(int p_iYear,
TimeZone p_tz) |
static Date |
getWhitSundayDate(Date p_dt,
TimeZone p_tz) |
static Date |
getWhitSundayDate(int p_iYear,
TimeZone p_tz) |
static long |
getWhitSundayDateInMillis(int p_iYear,
TimeZone p_tz) |
static <T extends Calendar> |
modifyCalendar(T p_cal,
String p_strRules)
Calls
modifyCalendar(Calendar, String, boolean) with the
third parameter set to false , so that the millisecond
field of the calendar is not being touched if the given rules do
not specify a rule for the millisecond field. |
static <T extends Calendar> |
modifyCalendar(T p_cal,
String p_strRules,
boolean p_bClearMillis)
Modify the given calendar according to the rules specified in the
p_strRules
parameter. |
static Date |
modifyDate(Date p_dt,
String p_strRules,
TimeZone p_tz)
Calls
modifyDate(Date, String, TimeZone, boolean) with the
fourth parameter set to false , so that the millisecond field
of the date is not being touched if the given rules do not specify a rule
for the millisecond field. |
static Date |
modifyDate(Date p_dt,
String p_strRules,
TimeZone p_tz,
boolean p_bClearMillis)
Modify the given date according to the rules specified in the
p_strRules
parameter. |
static long |
modifyDateInMillis(Date p_dt,
String p_strRules,
TimeZone p_tz)
Calls
modifyDateInMillis(Date, String, TimeZone, boolean) with the
fourth parameter set to false , so that the millisecond field
of the date is not being touched if the given rules do not specify a rule
for the millisecond field. |
static long |
modifyDateInMillis(Date p_dt,
String p_strRules,
TimeZone p_tz,
boolean p_bClearMillis)
Modify the given date according to the rules specified in the
p_strRules
parameter. |
static void |
setStartOfWeek(Calendar p_cal,
int p_iFirstDayOfWeek)
Set the given calendar to the start of the week.
|
public static Date modifyDate(Date p_dt, String p_strRules, TimeZone p_tz)
modifyDate(Date, String, TimeZone, boolean)
with the
fourth parameter set to false
, so that the millisecond field
of the date is not being touched if the given rules do not specify a rule
for the millisecond field.public static Date modifyDate(Date p_dt, String p_strRules, TimeZone p_tz, boolean p_bClearMillis)
p_strRules
parameter.
The rules consist of up to seven rules for each of the calendar fields YEAR
,
MONTH
, DAY_OF_MONTH
, HOUR_OF_DAY
, MINUTE
,
SECOND
, and MILLISECOND
, in that order, and separated by commas.
Each rule specifies either a positive or negative offset (e.g. -1
, or +1
),
or an absolute value for the field (e.g. 15
). Other than in the Java Calendar API,
the month values are, 1-based, i.e. 1 = January, 2 = February, ...
Example:
+1,1,1,12,30,0,0
means the given date plus one year, the first of January,
12:30:00.0 on the 24-hour clock.
p_dt
- The date to be modified.p_strRules
- The rules (must not be null
or empty).p_tz
- The time zone to be used.p_bClearMillis
- true
if the calendar's millisecond field should be set to
zero if the rule does not specify the millisecond field, or false
otherwise.IllegalArgumentException
- If p_strRules
is null
or empty.public static long modifyDateInMillis(Date p_dt, String p_strRules, TimeZone p_tz)
modifyDateInMillis(Date, String, TimeZone, boolean)
with the
fourth parameter set to false
, so that the millisecond field
of the date is not being touched if the given rules do not specify a rule
for the millisecond field.public static long modifyDateInMillis(Date p_dt, String p_strRules, TimeZone p_tz, boolean p_bClearMillis)
p_strRules
parameter.
The rules consist of up to seven rules for each of the calendar fields YEAR
,
MONTH
, DAY_OF_MONTH
, HOUR_OF_DAY
, MINUTE
,
SECOND
, and MILLISECOND
, in that order, and separated by commas.
Each rule specifies either a positive or negative offset (e.g. -1
, or +1
),
or an absolute value for the field (e.g. 15
). Other than in the Java Calendar API,
the month values are, 1-based, i.e. 1 = January, 2 = February, ...
Example:
+1,1,1,12,30,0,0
means the given date plus one year, the first of January,
12:30:00.0 on the 24-hour clock.
p_dt
- The date to be modified.p_strRules
- The rules (must not be null
or empty).p_tz
- The time zone to be used.p_bClearMillis
- true
if the calendar's millisecond field should be set to
zero if the rule does not specify the millisecond field, or false
otherwise.IllegalArgumentException
- If p_strRules
is null
or empty.public static <T extends Calendar> T modifyCalendar(T p_cal, String p_strRules)
modifyCalendar(Calendar, String, boolean)
with the
third parameter set to false
, so that the millisecond
field of the calendar is not being touched if the given rules do
not specify a rule for the millisecond field.p_cal
.public static <T extends Calendar> T modifyCalendar(T p_cal, String p_strRules, boolean p_bClearMillis)
p_strRules
parameter.
The rules consist of up to seven rules for each of the calendar fields YEAR
,
MONTH
, DAY_OF_MONTH
, HOUR_OF_DAY
, MINUTE
,
SECOND
, and MILLISECOND
, in that order, and separated by commas.
Each rule specifies either a positive or negative offset (e.g. -1
, or +1
),
or an absolute value for the field (e.g. 15
). Other than in the Java Calendar API,
the month values are, 1-based, i.e. 1 = January, 2 = February, ...
Example:
+1,1,1,12,30,0,0
means the given date plus one year, the first of January,
12:30:00.0 on the 24-hour clock.
p_cal
- The calendar to be modified.p_strRules
- The rules (must not be null
or empty).p_bClearMillis
- true
if the calendar's millisecond field should be set to
zero if the rule does not specify the millisecond field, or false
otherwise.p_cal
.IllegalArgumentException
- If p_strRules
is null
or empty.public static int getISO8601WeekNumber(Date p_dt, TimeZone p_tz)
p_dt
- The date.p_tz
- The time zone to be used.public static int getISO8601WeekNumber(int p_iYear, int p_iMonth, int p_iDay)
p_iYear
- The year.p_iMonth
- The month (0
for January, ...).p_iDay
- The day of month.public static int getISO8601WeekStartOffset(int p_iYear, int p_iWeek)
p_iYear
- The year.p_iWeek
- The week (1 is the first week of the year, 2 the second ...,
0 ist the last week of the year before, ...).public static Date getStartOfWeek(Date p_dt, int p_iFirstDayOfWeek, TimeZone p_tz)
p_dt
- The date.p_iFirstDayOfWeek
- The day the weeks starts with (1 for Sunday,
2 for Monday, ..., 7 for Saturday).p_tz
- The time zone.public static long getStartOfWeekInMillis(Date p_dt, int p_iFirstDayOfWeek, TimeZone p_tz)
p_dt
- The date.p_iFirstDayOfWeek
- The day the weeks starts with (1 for Sunday,
2 for Monday, ..., 7 for Saturday).p_tz
- The time zone.IllegalArgumentException
- If p_iFirstDayOfWeek
has an invalid
value.public static void setStartOfWeek(Calendar p_cal, int p_iFirstDayOfWeek)
p_cal
- The calendar.p_iFirstDayOfWeek
- The day the weeks starts with (1 for Sunday,
2 for Monday, ..., 7 for Saturday).IllegalArgumentException
- If p_iFirstDayOfWeek
has an invalid
value.public static int getQuarter(Date p_dt, TimeZone p_tz)
p_dt
- The date.p_tz
- The time zone.1
, 2
,
3
, or 4
.public static Date getStartOfQuarter(Date p_dt, TimeZone p_tz)
p_dt
- The date.p_tz
- The time zone.public static long getStartOfQuarterInMillis(Date p_dt, TimeZone p_tz)
p_dt
- The date.p_tz
- The time zone.public static long getNumberOfMidnightsBetween(Date p_dt1, Date p_dt2, TimeZone p_tz)
The result may be negative if the second date is before the first date.
p_dt1
- The first date.p_dt2
- The second date.p_tz
- The time zone.public static long getLunationNumber(Date p_dt)
p_dt
- The date for which the lunation number should be calculated.public static long getLunationNumber(long p_lTime)
p_lTime
- The date for which the lunation number should be calculated.public static long getMeeusLunationNumber(Date p_dt)
p_dt
- The date for which the lunation number should be calculated.public static long getMeeusLunationNumber(long p_lTime)
p_lTime
- The date for which the lunation number should be calculated.public static double getPhaseOfTheMoon(Date p_dt)
The result is a value greater or equal zero, and less than one, representing the phase of the moon from new moon to new moon.
p_dt
- The date for which the phase of the moon should be calculated.public static double getPhaseOfTheMoon(long p_lTime)
The result is a value greater or equal zero, and less than one, representing the phase of the moon from new moon to new moon.
p_lTime
- The date for which the phase of the moon should be calculated.public static long getShroveMondayDateInMillis(int p_iYear, TimeZone p_tz)
public static long getAshWednesdayDateInMillis(int p_iYear, TimeZone p_tz)
public static long getMaundyThursdayDateInMillis(int p_iYear, TimeZone p_tz)
public static long getGoodFridayDateInMillis(int p_iYear, TimeZone p_tz)
public static long getEasterDateInMillis(int p_iYear, TimeZone p_tz)
public static long getEasterMondayDateInMillis(int p_iYear, TimeZone p_tz)
public static long getAscensionDateInMillis(int p_iYear, TimeZone p_tz)
public static long getWhitSundayDateInMillis(int p_iYear, TimeZone p_tz)
public static long getWhitMondayDateInMillis(int p_iYear, TimeZone p_tz)
public static Date getPentecostDate(int p_iYear, TimeZone p_tz)
getWhitSundayDate(int, TimeZone)
.p_iYear
- The year.p_tz
- The time zone in which this date should be created.public static long getPentecostDateInMillis(int p_iYear, TimeZone p_tz)
getWhitSundayDate(int, TimeZone)
.p_iYear
- The year.p_tz
- The time zone in which this date should be created.public static long getCorpusChristiDateInMillis(int p_iYear, TimeZone p_tz)
public static long getPenanceDayDateInMillis(int p_iYear, TimeZone p_tz)