I'm enable to do use DateFormat
in flutter when am using the locale as 'ar'
which is RTL
locale .. here is my code :
String finalDatetime = '$dateString $timeString';
DateTime tempDate = new DateFormat("yyyy-MM-dd hh:mm").parse(finalDatetime);
String formattedDate = Intl.getCurrentLocale() == 'en' ? DateFormat('dd-MM-yyyy – hh:mm').format(tempDate)
:DateFormat.yMMMd('ar').format(tempDate);
I'm getting the error in this line :
DateTime tempDate = new DateFormat("yyyy-MM-dd hh:mm").parse(finalDatetime);
The error
FormatException: Trying to read yyyy from 2020-08-07 15:00 at position 0
NOTES
'en'
2020-08-07 15:00
as Jamesdlin
mentioned on his comment, using Intl.withLocale
fixed the problem
DateTime tempDate =Intl.withLocale('en', () => new DateFormat("yyyy-MM-dd hh:mm").parse(finalDatetime));