Reputation: 5118
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??
Upvotes: 2
Views: 9666
Reputation: 6738
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.
Upvotes: 0
Reputation: 1209
String myDate = new SimpleDateFormat("MM/dd/yyyy").format(currentdata.toDate());
Upvotes: 4