cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with Date.parse() function

VictorC
New Contributor

Hi, I have a problem with the Date.parse () function.
I cannot convert a String to date, the format of my string is the following: “dd/MM/yyyy”.
It only happens to me with some specific dates (with most data I have no problem).
The problem occurs with the following examples:
Date.parse (“01/04/1932”, “dd/MM/yyyy”)
Date.parse (“05/02/1939”, “dd/MM/yyyy”)
Date.parse (“09/12/1940”, “dd/MM/yyyy”)
Date.parse (“16/12/1943”, “dd/MM/yyyy”)
Date.parse (“12/02/1950”, “dd/MM/yyyy”)
And I always get a NaN as a result of the function.
Thank you.

10 REPLIES 10

For more examples of formatting, check out the SimpleDateFormat documentation. There are some examples on there that I’ve found helpful.

https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html