format method
Returns the formatted date and time string based on the provided
pattern
. If the pattern
is not provided, the method will return
the formatted date and time string in the ISO-8601 format.
Example:
// Formats the date and time in "dd MMM yyyy" format
final jiffy = Jiffy.parseFromList([1997, 9, 23, 11, 30, 22, 123, 456]);
final formattedDate = jiffy.format(pattern: 'dd MMM yyyy');
print(formattedDate);
// output: '23 Sep 1997'
// Formats the date and time in ISO8601 format
final jiffy = Jiffy.parseFromList([1997, 9, 23, 11, 30, 22, 123, 456]);
final formattedDate = jiffy.format(); // No pattern passed
print(formattedDate);
// output: '1997-09-23T11:30:22.123456'
Implementation
String format({String? pattern}) {
return pattern == null
? _display.formatToISO8601(dateTime)
: _display.format(dateTime, pattern, _locale);
}