FlutterDateFormatter class

A class that formats a DateTime object to a string, and parses strings in the same pattern.

An instance can be reused to format and parse any number of dates.

Constructors

FlutterDateFormatter([String? pattern, String? locale])
Creates a new instance of FlutterDateFormatter.

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

format(DateTime datetime) → String
Formats the given datetime according to the pattern provided.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
parse(String input, {bool strict = false, bool utc = false}) → DateTime
Parses input written in this formatter's pattern and locale, the reverse of format.
toString() → String
A string representation of this object.
inherited
tryParse(String input, {bool strict = false, bool utc = false}) → DateTime?
Like parse, but returns null instead of throwing when input does not match the pattern.

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

formatCalendar(DateTime datetime, {String? locale, DateTime? clock, String? timePattern, String? datePattern}) → String
Formats datetime relative to clock in calendar style:
formatDuration(Duration duration, {String? locale, bool short = false, int maxUnits = 2, Unit largestUnit = Unit.day, Unit smallestUnit = Unit.second, String? delimiter}) → String
Formats duration as text such as "2 hours 5 minutes", or "2h 5m" when short is true.
formatRelativeDateTime(DateTime datetime, {String? locale, DateTime? clock, bool short = false, bool withPrefixAndSuffix = true}) → String
Formats provided datetime to a fuzzy time like 'a moment ago'
ordinal(int n, {String? locale}) → String
Returns the ordinal number for the given n in the specified locale.