I tried to change string,which looks like this : 4th of July 2016
The code I tried to run is:
Date d = null;
String[] formats = {"d'st of' MMMMM yyyy","d'nd of' MMMMM yyyy","d'rd of' MMMMM yyyy","d'th of' MMMMM yyyy"};
for (String format : formats) {
try {
d = new SimpleDateFormat(format).parse(date);
}
catch (Exception e){
System.out.println("Error in ConvertStringToDate s" + e);
}
}
System.out.print(d.toString());
The error I was getting from the console:
Error in ConvertStringToDate sjava.text.ParseException: Unparseable date: "4th of July 2016"
Error in ConvertStringToDate sjava.text.ParseException: Unparseable date: "4th of July 2016"
Error in ConvertStringToDate sjava.text.ParseException: Unparseable date: "4th of July 2016"
Error in ConvertStringToDate sjava.text.ParseException: Unparseable date: "4th of July 2016"
Exception in thread "main" java.lang.NullPointerException
at MatchData.CollectMatch(MatchData.java:113)
at GetData.main(GetData.java:13)
Thank ahead to anyone who tries to help :)