62,621
社区成员
发帖
与我相关
我的任务
分享# public class TimeZoneTest
# {
# public static void main (String args[])
# {
# try
# {
# String ts = "2007-10-23T17:15:44.000Z";
# System.out.println("ts = " + ts);
# ts = ts.replace("Z", " UTC");
# System.out.println("ts = " + ts);
# SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS Z");
#
# Date dt = sdf.parse(ts);
#
#
# TimeZone tz = sdf.getTimeZone();
# Calendar c = sdf.getCalendar();
# System.out.println("Display name: " +
# tz.getDisplayName());
# System.out.println(getString(c));
# }
# catch(ParseException pe)
# {
# System.out.println("Error offset: " + pe.getErrorOffset());
# pe.printStackTrace();
# }
# }
#
#
# private static String getString(Calendar c)
# {
# StringBuffer result = new StringBuffer();
# result.append(c.get(Calendar.YEAR));
# result.append("-");
# result.append((c.get(Calendar.MONTH) + 1));
# result.append("-");
# result.append(c.get(Calendar.DAY_OF_MONTH));
# result.append(" ");
# result.append(c.get(Calendar.HOUR_OF_DAY));
# result.append(":");
# result.append(c.get(Calendar.MINUTE));
# result.append(":");
# result.append(c.get(Calendar.SECOND));
# return result.toString();
# }
#
#
#
# }