Parse and format Date in Android

Lian

I'm having a problem in parsing a date. I'm new on android and try to search for the solution but it seems no luck. I'd already tried to follow this one http://developer.android.com/reference/java/text/SimpleDateFormat.html but still got an error. please help me..

I try to parse this date 2014-03-18T02:07:35.742-0400 and try to format to this 03/18/2014 02:07

I got this error:

java.lang.IllegalArgumentException 
at java.text.DateFormat.format(DateFormat.java:361) 
at java.text.Format.format(Format.java:93)
DmitryKanunnikoff

Try something like this:

Date date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").parse("2014-03-18T02:07:35.742-0400");
System.out.println(new SimpleDateFormat("MM/dd/yyyy HH:mm").format(date));

For my time zone prints:

03/18/2014 10:07

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related