format method

String format([
  1. String? format,
  2. String? locale
])

Format the date using the specified format and locale.

  • If the format and locale 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 and locale 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);
}