Linked Questions

Popular Questions

java.text.ParseException: Unparseable date: "04-02-2019"

Asked by At

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)

Related Questions