toDate method

date toDate([
  1. string? format,
  2. string? locale
])

return a date from string

Implementation

date toDate([string? format, string? locale]) {
  try {
    locale ??= platformLocaleCode;
    initializeDateFormatting(locale);
    format ??= DateFormat.yMd(locale).pattern;
    return DateFormat(format, locale).parse(this);
  } catch (e) {
    return date.parse(this);
  }
}