1、UTC時(shí)間是l零時(shí)區的時(shí)間。(時(shí)間協(xié)調時(shí)間)
CST時(shí)間是四大時(shí)區的時(shí)間,(中央標準時(shí)間)
分別是:
- ??? Central Standard Time (USA) UT-6:00(美國cst時(shí)間:零區時(shí)減6個(gè)小時(shí))
- Central Standard Time (Australia) UT+9:30(澳大利亞cst:加9個(gè)半小時(shí))
- China Standard Time UT+8:00(中國cst:加8個(gè)小時(shí))
- Cuba Standard Time UT-4:00 (古巴cst:減4個(gè)小時(shí))
.
GMT=UTC
2、UTC(GMT)時(shí)間與CST時(shí)間的轉換
- 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格式類(lèi)似于:Thu, 02 Jul 2015 05:49:30 GMT ,能夠對應的把上面的格式調整為:
DateFormat df = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z", Locale.ENGLISH);
這樣的方式能夠靈活控制時(shí)間的格式,信息量較全,推薦使用。
聯(lián)系客服