format method

  1. @override
String format(
  1. DateTime date
)
override

Format the given date and return the formatted string.

The format specifiers are case-sensitive.

The following table lists the available format specifiers:

Specifier Meaning Example
YYYY Year with 4 digits 2019
YY Year with 2 digits 19
MMMM Month name January
... ... ...

Implementation

@override
String format(DateTime date) {
  final offset = date.timeZoneOffset;
  final sign = offset.isNegative ? '-' : '+';
  final hours = offset.inHours.abs().toString().padLeft(2, '0');
  final minutes = offset.inMinutes.abs().toString().padLeft(2, '0');
  return '$sign$hours:$minutes';
}