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)

SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");04-02-2019to04 Feb 2019then you need to read in the date and then reformat it. It cannot read it in and reformat at the same time.SimpleDateFormatand friends, and adding ThreeTenABP to your Android project in order to usejava.time, the modern Java date and time API. It is so much nicer to work with.