DateTimePrinter class

Prints DateTime objects in custom ways.

For example, to print dates in the format YYYY-MM-DD call the constructor and configure the printer as such:

final printer = DateTimePrinter((builder) => builder
    ..year(width: 4)
    ..literal('-')
    ..month(width: 2)
    ..literal('-')
    ..day(width: 2));
print(printer(DateTime(1975, 1, 9, 15, 45)));  // 1975-01-09
Inheritance

Constructors

DateTimePrinter(Callback1<DateTimePrinterBuilder> callback)
Constructor to build a DateTimePrinter.
factory

Properties

defaultToStringPrinter → ObjectPrinter
Override to configure the empty ObjectPrinter.
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
printers → Iterable<Printer<DateTime>>
finalinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
toStringPrinter → ObjectPrinter
Override and call super to add values to the ObjectPrinter.
no setterinherited

Methods

call(DateTime object) → String
Prints the object.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
print(DateTime object) → String
Returns the printed object.
inherited
printOn(DateTime object, StringBuffer buffer) → void
Prints the object into buffer.
inherited
toString() → String
Standard Object.toString implementation. Do not override, instead implement toStringPrinter to customize.
inherited

Operators

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

Static Methods

date({String separator = '-'}) → DateTimePrinter
Returns a configurable date printer.
dateTime({String dateSeparator = '-', String dateTimeSeparator = 'T', String timeSeparator = ':', bool milliseconds = true, bool microseconds = true}) → DateTimePrinter
Returns a configurable time printer.
iso8601() → DateTimePrinter
Returns an ISO-8601 full-precision extended format printer.
iso8691() → DateTimePrinter
time({String separator = ':', bool milliseconds = true, bool microseconds = true}) → DateTimePrinter
Returns a configurable time printer.