gpt4 book ai didi

flutter - 无法从格式化的DateString解析 “CET”

转载 作者:行者123 更新时间:2023-12-03 02:56:18 26 4
gpt4 key购买 nike

为什么DateFormat解析器无法解析CET?

final String dateString = "Sat Jul 05 00:00:00 CET 1975";
final DateTime dateTime =
DateFormat("EEE MMM dd HH:mm:ss vvv yyyy").parse(dateString);

结果是

FormatException: Trying to read from Sat Jul 05 00:00:00 CET 1975 at position 21



如果我算对的话,位置21将为“C”。

有人遇到过这个问题吗?

最佳答案

intl包尚未实现解析时区,如 date_format_field 类所示:

      case 'v':
return formatTimeZoneId(date);
case 'z':
return formatTimeZone(date);
case 'Z':
return formatTimeZoneRFC(date);

当您查看这些函数的实现时:
  String formatTimeZoneId(DateTime date) {
// TODO(alanknight): implement time zone support
throw new UnimplementedError();
}

String formatTimeZone(DateTime date) {
throw new UnimplementedError();
}

String formatTimeZoneRFC(DateTime date) {
throw new UnimplementedError();
}

这个 issue 自2015年以来一直开放,这是对此负责的人之一的回应:

We don't expect to implement those until Dart DateTime's have time zone information, and that's not planned. I wouldn't expect it unless/until JavaScript DateTime's have them. Including localized TimeZone names is a lot of data. We should probably just remove those APIs until such time as we actually provide them.

关于flutter - 无法从格式化的DateString解析 “CET”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57818440/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com