LocalDate class
- Implemented types
- Annotations
-
- @immutable
Constructors
- LocalDate(int year, int month, int day, [CalendarSystem? calendar, Era? era])
-
Constructs an instance for the given year, month and day in the specified or ISO calendar.
factory
- LocalDate.dateTime(DateTime dateTime, [CalendarSystem? calendar])
-
Converts a DateTime of any kind to a LocalDate in the specified or ISO calendar, ignoring the time of day.
This does not perform any time zone conversions, so a DateTime with a DateTime.isUtc of
true
will still represent the same year/month/day as it does in UTC - it won't be converted into the local system time.factory - LocalDate.fromEpochDay(int epochDay, [CalendarSystem? calendar])
-
Constructs an instance from the number of days since the unix epoch, in the specified
or ISO calendar system.
factory
- LocalDate.isoWeekDate(int weekYear, int weekOfWeekYear, DayOfWeek dayOfWeek)
-
Returns the local date corresponding to the given 'week year', "week of week year", and "day of week"
in the ISO calendar system, using the ISO week-year rules.
factory
- LocalDate.onDayOfWeekInMonth(int year, int month, int occurrence, DayOfWeek dayOfWeek)
-
Returns the local date corresponding to a particular occurrence of a day-of-week
within a year and month. For example, this method can be used to ask for 'the third Monday in April 2012'.
factory
- LocalDate.today([CalendarSystem? calendar])
-
Produces a LocalDate based on your Clock.current and your DateTimeZone.local.
factory
Properties
- calendar → CalendarSystem
-
Gets the calendar system associated with this local date.
no setter
- dayOfMonth → int
-
Gets the day of this local date within the month.
no setter
- dayOfWeek → DayOfWeek
-
Gets the week day of this local date expressed as an DayOfWeek value.
no setter
- dayOfYear → int
-
Gets the day of this local date within the year.
no setter
- epochDay → int
-
Gets the number of days since the Unix epoch for this date.
no setter
- era → Era
-
Gets the era of this local date.
no setter
- hashCode → int
-
Returns a hash code for this local date.
no setteroverride
- monthOfYear → int
-
Gets the month of this local date within the year.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- year → int
-
Gets the year of this local date.
This returns the 'absolute year', so, for the ISO calendar,
a value of 0 means 1 BC, for example.
no setter
- yearMonthDayCalendar → YearMonthDayCalendar
-
no setter
- yearOfEra → int
-
Gets the year of this local date within the era.
no setter
Methods
-
add(
Period period) → LocalDate -
Adds the specified period to this date. Fluent alternative to
operator+()
. -
addDays(
int days) → LocalDate - Returns a new LocalDate representing the current value with the given number of days added.
-
addMonths(
int months) → LocalDate - Returns a new LocalDate representing the current value with the given number of months added.
-
addWeeks(
int weeks) → LocalDate - Returns a new LocalDate representing the current value with the given number of weeks added.
-
addYears(
int years) → LocalDate - Returns a new LocalDate representing the current value with the given number of years added.
-
adjust(
LocalDate adjuster(LocalDate)) → LocalDate -
at(
LocalTime time) → LocalDateTime -
Combines this LocalDate with the given LocalTime
into a single LocalDateTime.
Fluent alternative to
operator+()
. -
atMidnight(
) → LocalDateTime - Gets a LocalDateTime at midnight on the date represented by this local date.
-
atStartOfDayInZone(
DateTimeZone zone) → ZonedDateTime - Resolves this local date into a ZonedDateTime in the given time zone representing the start of this date in the given zone.
-
compareTo(
LocalDate? other) → int -
Indicates whether this date is earlier, later or the same as another one.
override
-
equals(
LocalDate other) → bool - Compares two LocalDate values for equality. This requires that the dates be the same, within the same calendar.
-
next(
DayOfWeek targetDayOfWeek) → LocalDate - Returns the next LocalDate falling on the specified DayOfWeek. This is a strict 'next' - if this date on already falls on the target day of the week, the returned value will be a week later.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
periodSince(
LocalDate date) → Period -
Subtracts the specified time from this date, returning the result as a Period.
Cognitively similar to:
this - date
. -
periodUntil(
LocalDate date) → Period -
Subtracts the specified time from this time, returning the result as a Period.
Cognitively similar to:
date - this
. -
previous(
DayOfWeek targetDayOfWeek) → LocalDate - Returns the previous LocalDate falling on the specified DayOfWeek. This is a strict 'previous' - if this date on already falls on the target day of the week, the returned value will be a week earlier.
-
subtract(
Period period) → LocalDate -
Subtracts the specified period from this date. Fluent alternative to
operator-()
. -
subtractDays(
int days) → LocalDate -
subtractMonths(
int months) → LocalDate -
subtractWeeks(
int weeks) → LocalDate -
subtractYears(
int years) → LocalDate -
toDateTimeUnspecified(
) → DateTime -
Constructs a DateTime with DateTime.isUtc ==
false
. The result is midnight on the day represented by this value. -
toString(
[String? patternText, Culture? culture]) → String -
Returns a String that represents this instance.
override
-
withCalendar(
CalendarSystem calendar) → LocalDate - Creates a new LocalDate representing the same physical date, but in a different calendar. The returned LocalDate is likely to have different field values to this one. For example, January 1st 1970 in the Gregorian calendar was December 19th 1969 in the Julian calendar.
-
withOffset(
Offset offset) → OffsetDate - Returns an OffsetDate for this local date with the given offset.
Operators
-
operator +(
Period period) → LocalDate - Adds the specified period to the date.
-
operator -(
Period period) → LocalDate -
Subtracts the specified period from the date.
This is a convenience operator over the
Minus(Period)
method. -
operator <(
LocalDate other) → bool - Compares two dates to see if the left one is strictly earlier than the right one.
-
operator <=(
LocalDate other) → bool - Compares two dates to see if the left one is earlier than or equal to the right one.
-
operator ==(
Object other) → bool -
Compares two LocalDate values for equality. This requires
that the dates be the same, within the same calendar.
override
-
operator >(
LocalDate other) → bool - Compares two dates to see if the left one is strictly later than the right one.
-
operator >=(
LocalDate other) → bool - Compares two dates to see if the left one is later than or equal to the right one.
Static Properties
- maxIsoValue → LocalDate
-
The maximum (latest) date representable in the ISO calendar system.
no setter
- minIsoValue → LocalDate
-
The minimum (earliest) date representable in the ISO calendar system.
no setter
Static Methods
-
difference(
LocalDate end, LocalDate start) → Period - Subtracts one date from another, returning the result as a Period with units of years, months and days.
-
max(
LocalDate x, LocalDate y) → LocalDate - Returns the later date of the given two.
-
min(
LocalDate x, LocalDate y) → LocalDate - Returns the earlier date of the given two.
-
minus(
LocalDate date, Period period) → LocalDate -
Subtracts the specified period from the date. Friendly alternative to
operator-()
. -
plus(
LocalDate date, Period period) → LocalDate -
Adds the specified period to the date. Friendly alternative to
operator+()
.