I have an application that uses SimpleDateFormat
to parse dates. I suddenly had the urge to change my computer's display time format to a Chinese format and then left it at that to do something else.
When I went back to run my application several minutes later, I was getting "Unparseable date" errors for some reason. This never happened before; I never introduced any new code, so I was wondering what went wrong.
I then traced my actions and remembered I changed the format of the time display, so I changed it back and the application runs as usual.
Now, looking into the docs, I see that the library is locale-sensitive. Fortunately, this application is only for personal use where I have full control over my computer's settings. However, if I were to deploy an application for public consumption, I have no control over their environment, and so if I ever had a client that wasn't using US time format, they will be unhappy.
- Is this an issue in all datetime-parsing libraries?
- Are there "locale insensitive" libraries that will transparently handle locale detection for you? If so, what should I use?
- Should I avoid
SimpleDateFormat
completely because of this behaviour?