type
Date
@Serializable { simple=true }
const class Date : Obj
Date represents a day in time independent of a timezone.
constructors
fromStr |
Parse the string into a Date from the programmatic encoding defined by |
---|---|
make |
Make for the specified date values |
fields
defVal |
Default value is "2000-01-01". |
---|
methods
compare |
Compare based on year, month, and day. |
---|---|
day |
Get the day of the month as a number between 1 and 31. |
dayOfYear |
Return the day of the year as a number between 1 and 365 (or 1 to 366 if a leap year). |
equals |
Two dates are equal if have the same year, month, and day. |
firstOfMonth |
Get the first day of this Date's current month. |
fromIso |
Parse an ISO 8601 date. |
fromLocale |
Parse a string into a Date using the given pattern. |
hash |
Return hash of year, month, and day. |
isToday |
Return is this date equal to |
isTomorrow |
Return is this date equal to |
isYesterday |
Return is this date equal to |
lastOfMonth |
Get the last day of this Date's current month. |
midnight |
Return a DateTime for the beginning of the this day at midnight. |
minus |
Subtract the specified number of days to this date to get a date in the past. |
minusDate |
Return the delta between this and the given date. |
month |
Get the month of this date. |
plus |
Add the specified number of days to this date to get a date in the future. |
toCode |
Get this Date as a Fantom expression suitable for code generation. |
toDateTime |
Combine this Date with the given Time to return a DateTime. |
toIso |
Format this instance according to ISO 8601 using the pattern |
toLocale |
Format this date according to the specified pattern. |
toStr |
Return programmatic ISO 8601 string encoding formatted as follows |
today |
Get today's Date using specified timezone. |
tomorrow |
Get tomorrow's Date using specified timezone. |
weekOfYear |
Return the week number of the year as a number between 1 and 53 using the given weekday as the start of the week (defaults to current locale). |
weekday |
Get the day of the week for this date. |
year |
Get the year as a number such as 2009. |
yesterday |
Get yesterday's Date using specified timezone. |
Slot Details
compare
day
Int day()
Get the day of the month as a number between 1 and 31.
dayOfYear
Int dayOfYear()
Return the day of the year as a number between 1 and 365 (or 1 to 366 if a leap year).
defVal
const static Date defVal
Default value is "2000-01-01".
equals
firstOfMonth
Date firstOfMonth()
Get the first day of this Date's current month.
Example:
Date("2009-10-28").firstOfMonth => 2009-10-01
fromIso
fromLocale
fromStr
hash
virtual override Int hash()
Return hash of year, month, and day.
isToday
isTomorrow
isYesterday
lastOfMonth
Date lastOfMonth()
Get the last day of this Date's current month.
Example:
Date("2009-10-28").lastOfMonth => 2009-10-31
make
midnight
minus
minusDate
month
Month month()
Get the month of this date.
plus
toCode
Str toCode()
Get this Date as a Fantom expression suitable for code generation.
toDateTime
toIso
toLocale
Str toLocale(Str? pattern := null, Locale locale := Locale.cur())
Format this date according to the specified pattern. If pattern is null, then a localized default is used. The pattern format is the same as DateTime.toLocale
:
YY Two digit year 07 YYYY Four digit year 2007 M One/two digit month 6, 11 MM Two digit month 06, 11 MMM Three letter abbr month Jun, Nov MMMM Full month June, November D One/two digit day 5, 28 DD Two digit day 05, 28 DDD Day with suffix 1st, 2nd, 3rd, 24th WWW Three letter abbr weekday Tue WWWW Full weekday Tuesday Q Quarter number 3 QQQ Quarter with suffix 3rd QQQQ Quarter spelled out 3rd Quarter 'xyz' Literal characters
toStr
today
tomorrow
weekOfYear
weekday
Weekday weekday()
Get the day of the week for this date.
year
Int year()
Get the year as a number such as 2009.