Flutter Format Date

Viewed 45

I facing a problem while converting the 'String' date into DateTime format. My Client's data source date format is '27-JAN-2022'. But keep I getting below error.

Trying to read MMM from 27-JAN-2022 at position 3

I think it occurred based on the 'Month' value. Data Time can't identify 'JAN' but it's identified 'Jan'.

Please help me to convert the value.

1 Answers

You can use parseLoose method of DateFormat

DateFormat('dd-MMM-yyyy').parseLoose('27-JAN-2022')
Related