First of all , i know there are lots of questions regarding my same problem.But that was not enough to solve my problem.So if anyone can provide anything then it would be great. In my term the date comes as string format first and after that i need to convert it into date.But i was not able to do that.
I want the format as the format string has .Like as date should be as like as 04-02-2019.
Here is my java code:
Date date=null;
DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy");
try {
date=dateFormat.parse(paymentDate);
Log.v("Date:",""+date);
} catch (ParseException e) {
e.printStackTrace();
}
Note : paymentDate="04-02-2019" Exception:
java.text.ParseException: Unparseable date: "04-02-2019"
at java.text.DateFormat.parse(DateFormat.java:362)
Format dd-MMM-yyyy
means date in format 04 Feb 2019 // 25 Mar 1993 etc.
Replace it with dd-MM-yyyy
Please have a look once again at your complied files. It should work.
Here is the code running as online snippet: