Ahm*_*gdi 7 datetime android date ios dart
DateFormat当我使用以下语言环境时,\'ar\'我可以在 flutter 中使用RTL语言环境。这是我的代码:
String finalDatetime = \'$dateString $timeString\';\nDateTime tempDate = new DateFormat("yyyy-MM-dd hh:mm").parse(finalDatetime);\nString formattedDate = Intl.getCurrentLocale() == \'en\' ? DateFormat(\'dd-MM-yyyy \xe2\x80\x93 hh:mm\').format(tempDate)\n:DateFormat.yMMMd(\'ar\').format(tempDate);\nRun Code Online (Sandbox Code Playgroud)\n我在这一行收到错误:
\nDateTime tempDate = new DateFormat("yyyy-MM-dd hh:mm").parse(finalDatetime);\nRun Code Online (Sandbox Code Playgroud)\n错误
\nFormatException: Trying to read yyyy from 2020-08-07 15:00 at position 0\nRun Code Online (Sandbox Code Playgroud)\n笔记
\n\'en\'2020-08-07 15:00正如Jamesdlin他的评论中提到的,使用Intl.withLocale解决了问题
DateTime tempDate =Intl.withLocale('en', () => new DateFormat("yyyy-MM-dd hh:mm").parse(finalDatetime));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5462 次 |
| 最近记录: |