Question

I have my current data as 2012-08-20T12:30:00+05:30

  DateTime currentdata = "2012-08-20T12:30:00+05:30";

I am using

 String myDate = new SimpleDateFormat("MM/dd/yyyy").format(currentdata);

I get Cannot format given Object as a Date

Any clues??

Was it helpful?

Solution

String myDate = new SimpleDateFormat("MM/dd/yyyy").format(currentdata.toDate());

OTHER TIPS

 String myDate = new SimpleDateFormat("MM/dd/yyyy").format(currentdata);

According to this line, currentdata may access String or Object.

  DateTime currentdata = "2012-08-2012:30:00+05:30";

According to this line, current data may be Object.This is error point.'format' method access Date object.Change your data type.If you don't want to change this, change your currentdata (2012-08-20T12:30:00+05:30) to (2012-08-2012 30:05:30). If you won't, illegal argument exception may be occured.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top