【发布时间】:2016-07-10 11:59:36
【问题描述】:
我开始在我的 dart 项目中使用 intl 包。 开始使用这个包后,我使用这个代码:
DateTime now = new DateTime.now();
var formatter = new DateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
String nowFormatted = formatter.format(now);
而且它工作正常。 在我使用 intl 后,我在日志中获得了这条消息:
Uncaught LocaleDataException: Locale data has not been initialized, call initializeDateFormatting(<locale>).
我不明白为什么我应该在这段代码 sn-p 中传递语言环境
【问题讨论】:
-
它包含在 date_format.dart 中。在文件的标题中,我看到了 intl 的一部分;
-
@ThierryTemplier Dart
intl与 JSintl无关。 -
您的代码为我打印
2016-03-23T10:39:03Z。哪一行导致您的异常?您的pubspec.lock文件中列出了哪个版本的intl?
标签: internationalization dart intl