The best way to deal with dates that may have one or two digits per month / day

What is the best way to handle dates with days / months, possibly with one or two digits?

I have the following DateFormat :

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

and the application that I am processing succeeds until one day breaks because it received a date like this:

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

I came across this: Syntax date with a possible one-bit month / day / hour using java.text.SimpleDateFormat , but it did not answer my question.

Should I do some tweaking before the date string before? Or is there any other way to clean it?

Thanks.

+6
source share

Source: https://habr.com/ru/post/911375/


All Articles