getDateTime method

DateTime? getDateTime({
  1. bool? isUtc,
})

获取DateTime对象

Implementation

DateTime? getDateTime({bool? isUtc}) {
  if (this == null) {
    return null;
  }
  DateTime? dateTime = DateTime.tryParse(this!);
  if (isUtc != null) {
    if (isUtc) {
      dateTime = dateTime?.toUtc();
    } else {
      dateTime = dateTime?.toLocal();
    }
  }
  return dateTime;
}