开发者

Android - problem parsing date

I am using the following piece of code to parse a date -

DateFormat dateFormatIn = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'");
Strin开发者_如何转开发g ts = "2011-06-15T17:34:09.291Z";
String timestamp = dateFormatIn.format(ts);

It throws me an IllegalArgumentException. Any idea what is the right way to go about it?


DateFormat.format() expects a Date as parameter and not a String.

http://developer.android.com/reference/java/text/DateFormat.html#format(java.util.Date)

U need to use DateFormat.parse() to get the Date

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜