【发布时间】:2021-01-17 03:43:40
【问题描述】:
我正在尝试更改从 API 返回的日期字符串的格式。下面的日期格式输入字符串在 java 中可以正常工作,但在 Dart 中不行。
DateTime tempDate = new DateFormat("dd-MMM-yy hh.mm.ss.SSSSSS aa")
.parse(notification.createdat);
final DateFormat formatter = DateFormat('EEE M/d/yy h:mm a');
final String formatted = formatter.format(tempDate);
【问题讨论】:
-
这可能是因为
SEP都是大写的。您可以通过将带有Sep作为月份的静态字符串放入 parse 函数中来测试这一点。在此处检查正确的语法unicode-org.github.io/icu/userguide/format_parse/datetime/… -
@Er1 谢谢,它工作。如果您可以将其添加为答案,我认为对其他人会有所帮助。