
Flutter: Fixed formats for DateFormat
Obvious for some, but when you have users in different countries over the world using your mobile app. There isn’t a universal date format you can use. Users expect a date format that they use on a daily basis. The date format should be handled by the locale of the user configured on their phone.
Using a fixed format (like: yyyy-MM-dd’T’HH:mm:ss) for parsing the date that you receive from a server is ok. But if you need to present it to the user you should always use the static methods like below. (Flutter uses the current locale by default)
In my apps I define a date formatter as static final so that I can use it anywhere in the code.
by the author.