format method
Format the date using the specified format and locale.
- If the
format
andlocale
parameters are not provided, the date will be formatted using the ISO 8601 format. - If only the
format
parameter is provided, the date will be formatted using the specified format and the default locale. - If only the
locale
parameter is provided, the date will be formatted using the default format and the specified locale. - If both the
format
andlocale
parameters are provided, the date will be formatted using the specified format and locale.
Implementation
String format([String? format, String? locale]) {
if (format.isBlank && locale.isBlank) return toIso8601String();
if (locale.isBlank) locale = platformLocaleCode;
format = format.nullIfBlank;
return DateFormat(format, locale).format(this);
}