Date class

A date in the Gregorian calendar. It doesn't have a timezone.

final date = Date(2020, 12, 31);
Implemented types

Constructors

Date(int year, int month, int day)
Constructs a date from year, month, and day. [...]
const
Date.fromDateTime(DateTime dateTime)
Constructs a date from DateTime. [...]
factory

Properties

day int
Day. The first day of month is 1.
final
hashCode int
The hash code for this object. [...]
read-only, override
month int
Month. January is 1.
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
year int
Year.
final

Methods

compareTo(Date other) int
Compares this object to another Comparable [...]
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toDateTime({bool isUtc: false}) DateTime
Returns DateTime(year, month, day).
toString() String
Returns a string representation of this object.
override

Operators

operator ==(dynamic other) bool
The equality operator. [...]
override

Static Methods

now({bool isUtc: false}) Date
Returns the current date.
parse(String s) Date
Parses a string with format '2020-12-31'. Throws FormatException if the parsing fails.
tryParse(String s) Date
Parses a string with format '2020-12-31'. Returns null if parsing fails.