PlainDate class final
A calendar date (year, month, day) with no time component and no timezone.
Use PlainDate when you need to represent a date independently of time or location — e.g. a birthday, a deadline, or a recurring event.
- Implemented types
Constructors
- PlainDate.from(String iso)
-
Parses an ISO 8601 date string such as
'2024-03-15'.factory - PlainDate.now()
-
The current date in the system's local timezone.
factory
- PlainDate.of(int year, int month, int day, {Calendar? calendar})
-
Constructs a date from year, month, and day components.
factory
Properties
- calendar → Calendar
-
The calendar system for this date.
no setter
- day → int
-
no setter
- dayOfWeek → int
-
Day of the week: 1 (Monday) through 7 (Sunday), per ISO 8601.
no setter
- dayOfYear → int
-
Day of the year (1-based).
no setter
- daysInMonth → int
-
Total number of days in this date's month.
no setter
- daysInYear → int
-
Total number of days in this date's year.
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- inLeapYear → bool
-
no setter
- month → int
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- year → int
-
no setter
Methods
-
add(
TemporalDuration duration) → PlainDate -
Returns a new PlainDate with
durationadded. -
compareTo(
PlainDate other) → int -
Compares this object to another object.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
since(
PlainDate other) → TemporalDuration -
Returns the duration from
otherto this date. -
subtract(
TemporalDuration duration) → PlainDate -
Returns a new PlainDate with
durationsubtracted. -
toPlainDateTime(
[PlainTime? time]) → PlainDateTime -
Converts to a PlainDateTime by attaching
time(defaults to midnight). -
toString(
) → String -
Returns the ISO 8601 date string, e.g.
'2024-03-15'.override -
toZonedDateTime(
TimeZone timeZone, [PlainTime? time]) → ZonedDateTime -
Converts to a ZonedDateTime in the given
timeZone. -
until(
PlainDate other) → TemporalDuration -
Returns the duration from this date to
other. -
withCalendar(
Calendar calendar) → PlainDate - Returns a copy of this date with a different calendar.
Operators
-
operator <(
PlainDate other) → bool -
operator <=(
PlainDate other) → bool -
operator ==(
Object other) → bool -
The equality operator.
override
-
operator >(
PlainDate other) → bool -
operator >=(
PlainDate other) → bool