1、UTC時間是l零時區(qū)的時間。(時間協(xié)調時間)
CST時間是四大時區(qū)的時間,(中央標準時間)
分別是:
- ??? Central Standard Time (USA) UT-6:00(美國cst時間:零區(qū)時減6個小時)
- Central Standard Time (Australia) UT+9:30(澳大利亞cst:加9個半小時)
- China Standard Time UT+8:00(中國cst:加8個小時)
- Cuba Standard Time UT-4:00 (古巴cst:減4個小時)
.
GMT=UTC
2、UTC(GMT)時間與CST時間的轉換
- public Date getCST(String strGMT) throws ParseException {
- DateFormat df = new SimpleDateFormat("EEE, d-MMM-yyyy HH:mm:ss z", Locale.ENGLISH);
- return df.parse(strGMT);
- }
- public String getGMT(Date dateCST) {
- DateFormat df = new SimpleDateFormat("EEE, d-MMM-yyyy HH:mm:ss z", Locale.ENGLISH);
- df.setTimeZone(TimeZone.getTimeZone("GMT")); // modify Time Zone.
- return(df.format(dateCST));
- }
一般我們的web請求的請求頭中的Date格式類似于:Thu, 02 Jul 2015 05:49:30 GMT ,能夠對應的把上面的格式調整為:
DateFormat df = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z", Locale.ENGLISH);
這樣的方式能夠靈活控制時間的格式,信息量較全,推薦使用。