kgetDateTime method

DateTime? kgetDateTime({
  1. bool isUtc = false,
})

将字符串时间转化为DateTime

Implementation

DateTime? kgetDateTime({bool isUtc = false}) {
  var file = this;
  if (file == null || file.isEmpty) {
    return null;
  }
  DateTime? dateTime = DateTime.tryParse(file);
  if (isUtc) {
    dateTime = dateTime?.toUtc();
  } else {
    dateTime = dateTime?.toLocal();
  }
  return dateTime;
}