Cordelia
Cordelia

Reputation: 333

Flutter Format Date

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.

Upvotes: 1

Views: 128

Answers (1)

Rohit Suthar
Rohit Suthar

Reputation: 987

You can use parseLoose method of DateFormat

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

Upvotes: 1

Related Questions