6

What's the best way to handle dates with days/months possibly having a single or double digits?

I have the following DateFormat:

yyyy-MM-dd HH:mm:ss.SSS

and the application I'm handling is doing well until one day it broke because it received a date like this:

2012-03-5 00:00:00.001 (Notice the single digit day).

I stumbled across this: Parse date with possible single-digit month/day/hour using java.text.SimpleDateFormat but it did not answer my question.

Do I really have to do some tweaking to the date string prior? Or is there any other neater way?

Thanks.

Community
  • 1
  • 1
amor214
  • 201
  • 2
  • 11

0 Answers0