Ironman Ironman - 1 year ago 101
Java Question

Unable to parse Date it give ParseException in Java

I have this string

. when Parse with this format
it give me

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 Source

here's simple one..

SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy/MM/dd");
SimpleDateFormat outputFormat = new SimpleDateFormat("dd-MM-yyyy");
String dateText=outputFormat.format(inputFormat.parse(extras.GetString("Apodate")));
} catch (ParseException e) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download