【发布时间】:2012-07-21 13:51:48
【问题描述】:
我的当前数据为2012-08-20T12:30:00+05:30
DateTime currentdata = "2012-08-20T12:30:00+05:30";
我正在使用
String myDate = new SimpleDateFormat("MM/dd/yyyy").format(currentdata);
我收到Cannot format given Object as a Date
有什么线索吗??
【问题讨论】:
-
你试过
Date而不是DateTime吗? -
我只在我的请求中得到 DateTime..
-
你能用
Date dateOut = new Date(currentdata.getMillisecond());之类的东西转换,然后在你的格式调用中使用dateOut吗? -
@oneofthelions DateTime 是 joda.time 类吗?如果是,你可以简单地使用这样的东西:
String myDate = new SimpleDateFormat("MM/dd/yyyy").format(currentdata.toDate()); -
@AxxAOsiris 是的,它是 joda.time。谢谢,我现在就试试。
标签: java date time format datetimeformatinfo