久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何在 Java 中獲取 UTC 或 GMT 的當(dāng)前日期和時(shí)間

How can I get the current date and time in UTC or GMT in Java?(如何在 Java 中獲取 UTC 或 GMT 的當(dāng)前日期和時(shí)間?)
本文介紹了如何在 Java 中獲取 UTC 或 GMT 的當(dāng)前日期和時(shí)間?的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

When I create a new Date object, it is initialized to the current time but in the local timezone. How can I get the current date and time in GMT?

解決方案

java.util.Date has no specific time zone, although its value is most commonly thought of in relation to UTC. What makes you think it's in local time?

To be precise: the value within a java.util.Date is the number of milliseconds since the Unix epoch, which occurred at midnight January 1st 1970, UTC. The same epoch could also be described in other time zones, but the traditional description is in terms of UTC. As it's a number of milliseconds since a fixed epoch, the value within java.util.Date is the same around the world at any particular instant, regardless of local time zone.

I suspect the problem is that you're displaying it via an instance of Calendar which uses the local timezone, or possibly using Date.toString() which also uses the local timezone, or a SimpleDateFormat instance, which, by default, also uses local timezone.

If this isn't the problem, please post some sample code.

I would, however, recommend that you use Joda-Time anyway, which offers a much clearer API.

這篇關(guān)于如何在 Java 中獲取 UTC 或 GMT 的當(dāng)前日期和時(shí)間?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Upload progress listener not fired (Google drive API)(上傳進(jìn)度偵聽器未觸發(fā)(Google 驅(qū)動(dòng)器 API))
Save file in specific folder with Google Drive SDK(使用 Google Drive SDK 將文件保存在特定文件夾中)
Google Drive Android API - Invalid DriveId and Null ResourceId(Google Drive Android API - 無效的 DriveId 和 Null ResourceId)
Google drive api services account view uploaded files to google drive using java(谷歌驅(qū)動(dòng)api服務(wù)賬戶查看上傳文件到谷歌驅(qū)動(dòng)使用java)
Google Drive service account returns 403 usageLimits(Google Drive 服務(wù)帳號(hào)返回 403 usageLimits)
com.google.api.client.json.jackson.JacksonFactory; missing in Google Drive example(com.google.api.client.json.jackson.JacksonFactory;Google Drive 示例中缺少)
主站蜘蛛池模板: 涩涩视频网站在线观看 | 成人精品一区亚洲午夜久久久 | 久久久精品一区二区 | 毛片大全| 午夜视频一区二区 | 欧美伊人久久久久久久久影院 | 日本精品视频一区二区三区四区 | 精品二区| 亚洲视频在线播放 | 国产小视频在线 | 国产激情视频网 | 欧美三级久久久 | 欧美一区二区三区视频 | 日韩视频一区在线观看 | 久久丁香 | 久久免费资源 | 91免费视频 | 免费国产视频 | 国产精品久久网 | 农村妇女毛片精品久久久 | 羞羞视频免费观看入口 | 在线观看精品视频网站 | 午夜爱爱网 | 亚洲成人久久久 | 男人的天堂中文字幕 | 自拍 亚洲 欧美 老师 丝袜 | 91精品久久久久 | 国产精品亚洲一区二区三区在线 | 五月婷婷 六月丁香 | 欧美成人精品一区二区三区 | 香蕉国产在线视频 | 免费在线观看av | 91看片在线观看 | 激情五月婷婷综合 | 成人在线国产 | 高清视频一区二区三区 | 亚洲成人免费视频在线观看 | 久久美女视频 | 成人久久视频 | 欧美一区免费 | 国产精品美女久久久 |