toDateTime method

DateTime toDateTime()

将字符串解析为 DateTime 对象

支持 ISO 8601 格式的日期时间字符串 例如:'2024-01-17'、'2024-01-17 14:30:25'、'2024-01-17T14:30:25.000Z'

如果字符串格式不正确,将抛出 FormatException 异常

Implementation

DateTime toDateTime() {
  return DateTime.parse(this);
}