2

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??

Some Java Guy
  • 4,992
  • 19
  • 71
  • 108

2 Answers2

4
String myDate = new SimpleDateFormat("MM/dd/yyyy").format(currentdata.toDate());
AxxA Osiris
  • 1,219
  • 17
  • 26
0
 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.

Sai Ye Yan Naing Aye
  • 6,622
  • 12
  • 47
  • 65