Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Date

The Date class represents a day of the year. Date instances are immutable. The constructors are accessible from scripts.

Fields

FieldTypeDescription
theDayintegerAPI 1.18
Read only. Returns the day, from 1 to 31.
theMonthintegerAPI 1.18
Read only. Returns the month, from 0 to 11.
theYearintegerAPI 1.18
Read only. Returns the year.
theWeekdayintegerAPI 1.18
Read only. Returns the day of the week, from 1 (Sunday) to 7 (Saturday), same as the constants in the Java Calendar class.
daysFromSundayintegerRead only. The day of the week as a difference from Sunday: 0 for Sunday, 1 for Monday, etc.

Methods

init( )

Constructs a new Date instance for the current date.

init( year, month, day )

Constructs a new Date instance for the given year, month and day.

equals( object )

Returns True if object represents the same date as self.

compareTo( date )

Returns 0 if the date represented by the argument is equal to the date represented by this Date, less than 0 if the date of this Date is before the date represented by the argument, and greater than 0 if the date of this Calendar is after the date represented by the argument.

day( )

Returns the day, from 1 to 31. Same as theDay field.

month( )

Returns the month, from 0 to 11. Same as theMonth field.

year( )

Returns the year. Same as theYear field.

weekday( )

Returns the day of the week, from 1 (Sunday) to 7 (Saturday). Same as theWeekday field.

addDays( days )

Returns a new Date instance representing a date with the given number of days added to the date represented by this Date. The argument days can be negative.

addDays( workdays, workweek )

Returns a new Date instance representing a date with the given number of workdays added to the date represented by this Date and properly considering the Workweek represented by the parameter workweek. The argument workdays can be negative.