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
daysInWeek → int
no setter
daysInYear → int
Total number of days in this date's year.
no setter
era → String?
no setter
eraYear → int?
no setter
hashCode → int
The hash code for this object.
no setteroverride
inLeapYear → bool
no setter
month → int
no setter
monthCode → String
no setter
monthsInYear → int
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
weekOfYear → int?
no setter
year → int
no setter
yearOfWeek → int?
no setter

Methods

add(TemporalDuration duration, {TemporalOverflow? overflow}) → PlainDate
Returns a new PlainDate with duration added.
compareTo(PlainDate other) → int
Compares this object to another object.
override
copyWith({int? year, int? month, String? monthCode, int? day, String? era, int? eraYear, Calendar? calendar}) → PlainDate
Returns a copy with selected fields replaced.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
since(PlainDate other, {TemporalDifferenceOptions? options}) → TemporalDuration
Returns the duration from other to this date.
subtract(TemporalDuration duration, {TemporalOverflow? overflow}) → PlainDate
Returns a new PlainDate with duration subtracted.
toIsoString([TemporalToStringOptions? options]) → String
Returns an ISO 8601 date string using Temporal string options.
toPlainDateTime([PlainTime? time]) → PlainDateTime
Converts to a PlainDateTime by attaching time (defaults to midnight).
toPlainMonthDay() → PlainMonthDay
toPlainYearMonth() → PlainYearMonth
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, {TemporalDifferenceOptions? options}) → 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