Ironman Ironman - 10 days ago 6
Java Question

Unable to parse Date it give ParseException in Java

I have this string

2016/11/29
. when Parse with this format
dd-MM-yyyy
it give me
ParseException
.

The code I use it

SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
tie_datetime.Text = sdf.Parse(extras.GetString("Apodate"));


it is give below exception :

enter image description here

UpDate :
@Ravi Rupareliya comment

When I use
sdf.parse(new SimpleDateFormat("yyyy/MM/dd").format(extras.GetString("Apod‌​ate")))


it give below
enter image description here

Answer

here's simple one..

SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy/MM/dd");
SimpleDateFormat outputFormat = new SimpleDateFormat("dd-MM-yyyy");
try{
String dateText=outputFormat.format(inputFormat.parse(extras.GetString("Apodate")));
} catch (ParseException e) {
    e.printStackTrace();
}