add(field
:
Number, value
:
Number)
:
void
Adds or subtracts the specified amount of time to the given calendar field, based on the calendar's rules.
after(obj
:
Object)
:
boolean
Indicates if this Calendar represents a time after the time represented by the specified Object.
before(obj
:
Object)
:
boolean
Indicates if this Calendar represents a time before the time represented by the specified Object.
clear()
:
void
Sets all the calendar field values and the time value (millisecond offset from the Epoch) of this Calendar undefined.
clear(field
:
Number)
:
void
Sets the given calendar field value and the time value (millisecond offset from the Epoch) of this Calendar undefined.
compareTo(anotherCalendar
:
Calendar)
:
Number
Compares the time values (millisecond offsets from the Epoch) represented by two Calendar objects.
equals(other
:
Object)
:
boolean
Compares two calendar values whether they are equivalent.
get(field
:
Number)
:
Number
Returns the value of the given calendar field.
getTime()
:
Date
Returns the current time stamp of this calendar.
isLeapYear(year
:
Number)
:
boolean
Indicates if the specified year is a leap year.
isSameDay(other
:
Calendar)
:
boolean
Checks, whether two calendar dates fall on the same day.
isSet(field
:
Number)
:
boolean
Indicates if the field is set.
parseByFormat(timeString
:
String, format
:
String)
:
void
Parses the string according to the date and time format pattern and set the time at this calendar object.
roll(field
:
Number, up
:
boolean)
:
void
Rolls the specified field up or down one value.
roll(field
:
Number, amount
:
Number)
:
void
Rolls the specified field using the specified value.
set(field
:
Number, value
:
Number)
:
void
Sets the given calendar field to the given value.
set(year
:
Number, month
:
Number, date
:
Number)
:
void
Sets the values for the calendar fields YEAR, MONTH, and DAY_OF_MONTH.
set(year
:
Number, month
:
Number, date
:
Number, hourOfDay
:
Number, minute
:
Number)
:
void
Sets the values for the calendar fields YEAR, MONTH, DAY_OF_MONTH, HOUR_OF_DAY, and MINUTE.
set(year
:
Number, month
:
Number, date
:
Number, hourOfDay
:
Number, minute
:
Number, second
:
Number)
:
void
Sets the values for the calendar fields YEAR, MONTH, DAY_OF_MONTH, HOUR_OF_DAY, MINUTE and SECOND.
setTime(date
:
Date)
:
void
Sets the current time stamp of this calendar.
WARNING: Keep in mind that the set Date object's time is always interpreted in the time zone GMT.
setTimeZone(timeZone
:
String)
:
void
Sets the current time zone of this calendar.
WARNING: Keep in mind that the time stamp represented by the calendar is always interpreted in the time zone GMT.
add
Adds or subtracts the specified amount of time to the given
calendar field, based on the calendar's rules.
Parameters:
field
-
the calendar field.
value
-
the amount of date or time to be added to the field
after
Indicates if this Calendar represents a time after
the time represented by the specified Object.
Parameters:
obj
-
the object to test.
Returns:
true if this Calendar represents a time after the time represented by the specified Object, false otherwise.
before
before(obj
:
Object)
:
boolean
Indicates if this Calendar represents a time before
the time represented by the specified Object.
Parameters:
obj
-
the object to test.
Returns:
true if this Calendar represents a time before the time represented by the specified Object, false otherwise.
clear
clear()
:
void
Sets all the calendar field values and the time value
(millisecond offset from the Epoch) of this Calendar undefined.
clear
Sets the given calendar field value and the time value
(millisecond offset from the Epoch) of this Calendar undefined.
Parameters:
field
-
the calendar field to be cleared.
compareTo
Compares the time values (millisecond offsets from the Epoch)
represented by two Calendar objects.
Parameters:
anotherCalendar
-
the Calendar to be compared.
Returns:
the value 0 if the time represented by the argument is equal to the time represented by this Calendar; a value less than 0 if the time of this Calendar is before the time represented by the argument; and a value greater than 0 if the time of this Calendar is after the time represented by the argument.
equals
equals(other
:
Object)
:
boolean
Compares two calendar values whether they are equivalent.
Parameters:
other
-
the object to compare against this calendar.
get
Returns the value of the given calendar field.
Parameters:
field
-
the calendar field to retrieve.
Returns:
the value for the given calendar field.
getActualMaximum
Returns the maximum value that the specified calendar
field could have.
Parameters:
field
-
the calendar field.
Returns:
the maximum value that the specified calendar field could have.
getActualMinimum
Returns the minimum value that the specified calendar
field could have.
Parameters:
field
-
the calendar field.
Returns:
the minimum value that the specified calendar field could have.
getFirstDayOfWeek
Returns the first day of the week base on locale context. For example, in the US
the first day of the week is SUNDAY. However, in France the
first day of the week is MONDAY.
Returns:
the first day of the week base on locale context. For example, in the US the first day of the week is SUNDAY. However, in France the first day of the week is MONDAY.
getMaximum
Returns the maximum value for the given calendar
field.
Parameters:
field
-
the calendar field.
Returns:
the maximum value for the given calendar field.
getMinimum
Returns the minimum value for the given calendar
field.
Parameters:
field
-
the calendar field.
Returns:
the minimum value for the given calendar field.
getTime
Returns the current time stamp of this calendar. This method
is also used to convert a Calendar into a Date.
WARNING: Keep in mind that the returned Date object's time is always
interpreted in the time zone GMT. This means time zone information
set at the calendar object will not be honored and gets lost.
Returns:
the current time stamp of this calendar as a Date.
getTimeZone
Returns the current time zone of this calendar.
Returns:
the current time zone of this calendar.
hashCode
Calculates the hash code for a calendar;
isLeapYear
isLeapYear(year
:
Number)
:
boolean
Indicates if the specified year is a leap year.
Parameters:
year
-
the year to test.
Returns:
true if the specified year is a leap year.
isSameDay
Checks, whether two calendar dates fall on the same day.
The method performs comparison based on both calendar's
field values by honoring the defined time zones.
Examples:
new Calendar( new Date( "2002/02/28 13:45" ).isSameDay( new Calendar( new Date( "2002/02/28 06:01" ) ) );
would return true.
new Calendar( new Date( "2002/02/28 13:45" ).isSameDay( new Calendar( new Date( "2002/02/12 13:45" ) ) );
would return false.
new Calendar( new Date( "2002/02/28 13:45" ).isSameDay( new Calendar( new Date( "1970/02/28 13:45" ) ) );
would return false.
var cal1 = new Calendar( new Date( "2002/02/28 02:00" );
cal1.setTimeZone( "Etc/GMT+1" );
var cal2 = new Calendar( new Date( "2002/02/28 00:00" );
cal2.setTimeZone( "Etc/GMT+1" );
cal1.isSameDay( cal2 );
would return false since the time zone is applied first which results in comparing
2002/02/28 01:00
for
cal1
with
2002/02/27 23:00
for
cal2
.
Parameters:
other
-
the calendar to compare against this calendar.
isSameDayByTimestamp
isSameDayByTimestamp(other
:
Calendar)
:
boolean
Checks, whether two calendar dates fall on the same day.
The method performs comparison based on both calendar's
time stamps by ignoring any defined time zones.
Examples:
new Calendar( new Date( "2002/02/28 13:45" ).isSameDayByTimestamp( new Calendar( new Date( "2002/02/28 06:01" ) ) );
would return true.
new Calendar( new Date( "2002/02/28 13:45" ).isSameDayByTimestamp( new Calendar( new Date( "2002/02/12 13:45" ) ) );
would return false.
new Calendar( new Date( "2002/02/28 13:45" ).isSameDayByTimestamp( new Calendar( new Date( "1970/02/28 13:45" ) ) );
would return false.
var cal1 = new Calendar( new Date( "2002/02/28 02:00" );
cal1.setTimeZone( "Etc/GMT+1" );
var cal2 = new Calendar( new Date( "2002/02/28 00:00" );
cal2.setTimeZone( "Etc/GMT+1" );
cal1.isSameDayByTimestamp( cal2 );
would return true since the time zone is not applied first which results in comparing
2002/02/28 02:00
for
cal1
with
2002/02/28 00:00
for
cal2
.
Parameters:
other
-
the calendar to compare against this calendar.
isSet
isSet(field
:
Number)
:
boolean
Indicates if the field is set.
Parameters:
field
-
the field to test.
Returns:
true if the field is set, false otherwise.
parseByFormat
Parses the string according to the date and time format pattern and set
the time at this calendar object. For the specification of the date and
time format pattern see the javadoc of the JDK class java.text.SimpleDateFormat.
If a time zone is included in the format string,
this time zone is used to interpet the time. Otherwise the currently set
calendar time zone is used to parse the given time string.
Parameters:
timeString
-
the time string to parsed
format
-
the time format string
parseByLocale
Parses the string according the date format pattern of the given locale.
If the locale name is invalid, an exception is thrown. The currently set
calendar time zone is used to parse the given time string.
Parameters:
timeString
-
the time string to parsed
locale
-
the locale id, which defines the date format pattern
pattern
-
the pattern is one of calendar pattern e.g. SHORT_DATE_PATTERN as defined in the regional settings for the locale
roll
roll(field
:
Number, up
:
boolean)
:
void
Rolls the specified field up or down one value.
Parameters:
field
-
the field to roll.
up
-
if true rolls the field up, if false rolls the field down.
roll
Rolls the specified field using the specified value.
Parameters:
field
-
the field to roll.
amount
-
the amount to roll the field.
set
Sets the given calendar field to the given value.
Parameters:
field
-
the calendar field to set.
value
-
the value to set in the field.
set
Sets the values for the calendar fields YEAR, MONTH, and DAY_OF_MONTH.
Parameters:
year
-
the value for year.
month
-
the value for month.
date
-
the value for date.
set
Sets the values for the calendar fields YEAR, MONTH,
DAY_OF_MONTH, HOUR_OF_DAY, and MINUTE.
Parameters:
year
-
the value for year.
month
-
the value for month.
date
-
the value for date.
hourOfDay
-
the value for hour of day.
minute
-
the value for minute.
set
Sets the values for the calendar fields YEAR, MONTH,
DAY_OF_MONTH, HOUR_OF_DAY, MINUTE and SECOND.
Parameters:
year
-
the value for year.
month
-
the value for month.
date
-
the value for date.
hourOfDay
-
the value for hour of day.
minute
-
the value for minute.
second
-
the value for second.
setFirstDayOfWeek
setFirstDayOfWeek(value
:
Number)
:
void
Sets what the first day of the week is.
Parameters:
value
-
the day to set as the first day of the week.
setTime
setTime(date
:
Date)
:
void
Sets the current time stamp of this calendar.
WARNING: Keep in mind that the set Date object's time is always
interpreted in the time zone GMT. This means that time zone
information at the calendar object needs to be set separately by
using the
setTimeZone(String) method.
Parameters:
date
-
the current time stamp of this calendar.
setTimeZone
setTimeZone(timeZone
:
String)
:
void
Sets the current time zone of this calendar.
WARNING: Keep in mind that the time stamp represented by the calendar is
always interpreted in the time zone GMT. Changing the time zone will not
change the calendar's time stamp.
Parameters:
timeZone
-
the current time zone value to set.