toDateTime static method

DateTime toDateTime(
  1. dynamic object, {
  2. dynamic mapKey,
  3. int? listIndex,
  4. String? format,
  5. String? locale,
  6. bool autoDetectFormat = false,
  7. bool useCurrentLocale = false,
  8. bool utc = false,
  9. DateTime? defaultValue,
  10. ElementConverter<DateTime>? converter,
})

Converts object to a DateTime, respecting DateOptions defaults.

Calendar-like inputs (e.g. yyyyMMdd, MM/dd/yyyy, long month names) return a value in the local time zone unless utc is true. Instant inputs (ISO strings with offsets, HTTP dates, Unix epochs) preserve their UTC meaning but are converted back to local time if utc is false.

format, locale, and flags override DateOptions for this call. Numeric inputs are treated as seconds or milliseconds since epoch.

Implementation

static DateTime toDateTime(
  dynamic object, {
  dynamic mapKey,
  int? listIndex,
  String? format,
  String? locale,
  bool autoDetectFormat = false,
  bool useCurrentLocale = false,
  bool utc = false,
  DateTime? defaultValue,
  ElementConverter<DateTime>? converter,
}) => ConvertObjectImpl.toDateTime(
  object,
  mapKey: mapKey,
  listIndex: listIndex,
  format: format,
  locale: locale,
  autoDetectFormat: autoDetectFormat,
  useCurrentLocale: useCurrentLocale,
  utc: utc,
  defaultValue: defaultValue,
  converter: converter,
);