toDateTimeJson static method

DateTime? toDateTimeJson(
  1. dynamic json
)

Converts JSON to a DateTime.

Implementation

static DateTime? toDateTimeJson(dynamic json) {
  if (json == null) return null;
  if (json is DateTime) return json;
  if (json is int) return DateTime.fromMillisecondsSinceEpoch(json);
  final String? str = toStringJson(json);
  if (str == null || str.isEmpty) return null;
  return DateTime.tryParse(str);
}