Czeslaw Czeslaw Czeslaw Czeslaw - 5 months ago 20
Java Question

Date format parsing string java

I got function:

public boolean isValidDate(String inDate) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:sssZ");
try {
} catch (ParseException pe) {
return false;
return true;

And I need to verify if string: '
' is date, but funtion always return false. Could anybody tell me if my dateDormat:
is correct?
I read a lot of questions about formatting date, but I think my dateFormat is still not correct.


I guess the :sss part of the format is not correct. That would be 3 seconds, no Millis and a missing dot.

It should be :


To debug this: Have the formatter format the actual date, then look at the output and see if it matches what you are trying to parse.

The above pattern is actually taken from Examples Section.

In Java 8 you should use the new Date/Time classes like described in this answer.