I am trying to convert the date time in the string format to DateTime but its showing "FormatException (FormatException: Trying to read dd from MONDAY at position 0)"
safePrint(Intl.withLocale(
'en',
() => new DateFormat("dd, EEE MMM yyyy HH:mm:ss \'GMT\'")
.parse(batch_timing[j])));
print(new DateFormat('dd, EEE MMM yyyy HH:mm:ss \'GMT\'')
.parse(batch_timing[j]));
Note : date format is "Mon, 05 Sep 2022 10:00:00 GMT"
CodePudding user response:
There is a correction in converting :
check the below
String mDate ="Mon, 05 Sep 2022 10:00:00 GMT";
print(DateFormat('EEE, dd MMM yyyy HH:mm:ss \'GMT\'')
.parse(mDate));
you have to use EEE, dd MMM yyyy HH:mm:ss \'GMT\''
instead of dd, EEE MMM yyyy HH:mm:ss \'GMT\''