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
datetimeaccording 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
inputwritten 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
nullinstead of throwing wheninputdoes 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
datetimerelative toclockin 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
durationas text such as "2 hours 5 minutes", or "2h 5m" whenshortistrue. -
formatRelativeDateTime(
DateTime datetime, {String? locale, DateTime? clock, bool short = false, bool withPrefixAndSuffix = true}) → String -
Formats provided
datetimeto a fuzzy time like 'a moment ago' -
ordinal(
int n, {String? locale}) → String -
Returns the ordinal number for the given
nin the specifiedlocale.