I want the Input string which is of pattern "yyyy.MM.dd HH.mm.ss.S" to be converted to Date. The Input string is 1988.07.29 12:12:12.123
I have done it in the following way:
SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
Date date = dateFormat.parse(value);
I get ParseException saying the entered date is unparseable.
First Thing, does my pattern correspond to the Input string? If yes what am i doing wrong here?
You have to use colons instead of dots in the pattern:
yyyy.MM.dd HH:mm:ss.S
Characters from A
to Z
and from a
to z
are interpreted as special characters. All other characters in the pattern are matched as they are. See https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html for more details.