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
- It works perfectly when the locale is set to
'en'
- The date string is being fetched from a database which is always sent as
2020-08-07 15:00