Timestamp 时区
Calendar cal = Calendar.getInstance();
Date date = cal.getTime();
System.out.println(date);
Timestamp time = new Timestamp(date.getTime());
System.out.println("time: "+time);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSz");
sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
// sdf.setTimeZone(cal.getTimeZone());
String sdate = sdf.format(date);
System.out.println(sdate);
System.out.println(cal.getTimeZone().getDisplayName());
System.out.println(TimeZone.getTimeZone("GMT+8").getID());
---------------------------------
Wed Jun 19 16:31:19 CST 2013
time: 2013-06-19 16:31:19.306
2013-06-19T16:31:19.000306GMT+08:00
中国标准时间
GMT+08:00
-------------------------------------
GregorianCalendar cal = new GregorianCalendar();
try {
String value = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal).toString();
System.out.println(value);
} catch (DatatypeConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
------------------------------------------
2013-06-19T16:38:21.823+08:00
----------------------------------