format method

String format({
  1. List<String>? formatStyle = defaultFormatStyle,
})

Builds a formatted date/time string by evaluating each token in formatStyle against this Moment's values.

Tokens that don't match a known format specifier are passed through as literal strings, so you can mix separators and text freely.

final m = Moment.now();
m.format(formatStyle: [dddd, comma, space, mmmm, space, D, comma, space, yyyy]);
// → "Wednesday, February 19, 2026"

Implementation

String format({List<String>? formatStyle = defaultFormatStyle}) {
  String val = '';
  for (int i = 0; i < formatStyle!.length; i++) {
    val += formatToken(this, formatStyle[i]).toString();
  }
  return val;
}