SimpleDateFormat is a simple format that requires passing in the specified parameters, including parameter names and formats, to match the string to parse;
Android api:http://developer.android.com/reference/java/text/simpledateformat.html
How to use:
SimpleDateFormat SDF = new SimpleDateFormat ("Yyyy-mm-dd ' T" hh:mm:ss. SSS ' Z ');
Date qdate = new GregorianCalendar (0,0,0). GetTime ();
try {
qdate = sdf.parse (dt);
} catch (ParseException e) {
log.d (TAG, "Date parsing exception.", E);
}
DT is the label format for XML, as follows:
<updated>2014-03-24T07:48:34.609Z</updated>
The specified style needs to be matched, otherwise it cannot be resolved;
namely: Yyyy-mm-dd ' T ' hh:mm:ss. SSS ' Z '
You can also use the Convert to string format
Such as:
SimpleDateFormat SDF = new SimpleDateFormat ("hh.mm");
String datestring = Sdf.format (date);
Author: csdn Blog spike_king
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/extra/