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

基于 TimeZone Java/Groovy 的日期時間轉換

Date Time Conversion based on the TimeZone Java/Groovy(基于 TimeZone Java/Groovy 的日期時間轉換)
本文介紹了基于 TimeZone Java/Groovy 的日期時間轉換的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我在 MST,我希望我的日期在 PST.我設置了我想要的時區.現在,如果我這樣做 c.getTime() 我總是得到我的服務器時間.相反,我想要太平洋日期時間.請幫忙如何獲取指定時區的日期時間對象.

I am in MST and I want my Date in PST. I set the timeZone that I want. Now if i do c.getTime() I always get my server time. Instead I want Pacific Date time. Please help How to get the date time Object in the specified timezone.

   Calendar c= Calendar.getInstance();
   TimeZone timezone= TimeZone.getTimeZone("PST"); 
   c.setTimeZone(timezone)

推薦答案

更新: Joda-Time 項目已經被 java.time 類.請參閱其他答案.

UPDATE: The Joda-Time project has been succeeded by the java.time classes. See this other Answer.

(a) 使用 Joda-Time(或 Java 8 中內置的新 JSR 310).甚至不要考慮使用臭名昭著的糟糕 java.util.Date/Calendar.

(a) Use Joda-Time (or new JSR 310 built into Java 8). Don't even think about using the notoriously bad java.util.Date/Calendar.

(b) 你的問題不清楚.您對答案的評論談論比較,但您在問題中沒有提及比較.

(b) Your question is not clear. Your comments on answers talk about comparing, but you say nothing about comparing in your question.

(c) 避免使用 3 個字母的時區縮寫.閱讀 Joda-Time 文檔中關于 TimeZone<的棄用說明/a> 類.

(c) Avoid the use of 3-letter time zone abbreviations. Read note of deprecation in Joda-Time doc for TimeZone class.

(d) 避免使用默認時區.說出你的意思.您計算機的時區可以有意或無意更改.

(d) Avoid default time zone. Say what you mean. The time zone of your computer can change intentionally or not.

(e) 在 StackOverflow 中搜索joda"以獲取大量代碼片段和示例.

(e) Search StackOverflow for 'joda' for lots of code snippets and examples.

(f) 這里有一些 Joda-Time 示例代碼可以幫助您入門.

(f) Here's some Joda-Time example code to get you started.

// ? 2013 Basil Bourque. This source code may be used freely forever by anyone taking full responsibility for doing so.

// Specify your time zone rather than rely on default.
org.joda.time.DateTimeZone californiaTimeZone = org.joda.time.DateTimeZone.forID( "America/Los_Angeles" );
org.joda.time.DateTimeZone denverTimeZone = org.joda.time.DateTimeZone.forID( "America/Denver" );

org.joda.time.DateTime nowDenver = new org.joda.time.DateTime( denverTimeZone );
org.joda.time.DateTime nowCalifornia = nowDenver.toDateTime( californiaTimeZone );

// Same moment in the Universe’s timeline, but presented in the local context.
System.out.println( "nowDenver: " + nowDenver );
System.out.println( "nowCalifornia: " + nowCalifornia );

運行時……

nowDenver: 2013-11-21T18:12:49.372-07:00
nowCalifornia: 2013-11-21T17:12:49.372-08:00

關于 Joda-Time…

About Joda-Time…

// Joda-Time - The popular alternative to Sun/Oracle's notoriously bad date, time, and calendar classes bundled with Java 7 and earlier.
// http://www.joda.org/joda-time/

// Joda-Time will become outmoded by the JSR 310 Date and Time API introduced in Java 8.
// JSR 310 was inspired by Joda-Time but is not directly based on it.
// http://jcp.org/en/jsr/detail?id=310

// By default, Joda-Time produces strings in the standard ISO 8601 format.
// https://en.wikipedia.org/wiki/ISO_8601

// About Daylight Saving Time (DST): https://en.wikipedia.org/wiki/Daylight_saving_time

// Time Zone list: http://joda-time.sourceforge.net/timezones.html

這篇關于基于 TimeZone Java/Groovy 的日期時間轉換的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

Parsing an ISO 8601 string local date-time as if in UTC(解析 ISO 8601 字符串本地日期時間,就像在 UTC 中一樣)
How to convert Gregorian string to Gregorian Calendar?(如何將公歷字符串轉換為公歷?)
Java: What/where are the maximum and minimum values of a GregorianCalendar?(Java:GregorianCalendar 的最大值和最小值是什么/在哪里?)
Calendar to Date conversion for dates before 15 Oct 1582. Gregorian to Julian calendar switch(1582 年 10 月 15 日之前日期的日歷到日期轉換.公歷到儒略歷切換)
java Calendar setFirstDayOfWeek not working(java日歷setFirstDayOfWeek不起作用)
Java: getting current Day of the Week value(Java:獲取當前星期幾的值)
主站蜘蛛池模板: 精品欧美一区二区三区久久久小说 | 免费观看一级特黄欧美大片 | 精品国产一区二区三区在线观看 | 伊人精品视频 | 91视频官网 | 黄色免费网 | 午夜影院网站 | 亚洲国产一 | 亚洲欧美综合精品久久成人 | 精品久久久久香蕉网 | 久久精品亚洲精品国产欧美 | 国产精品三级久久久久久电影 | 国产精品视频一区二区三区不卡 | 久久国产99 | 龙珠z在线观看 | 亚洲一区二区三区在线免费 | 亚洲a网 | 国产成人在线播放 | 国产精品视频不卡 | 色综久久| 国产精品一级在线观看 | 搞av.com| 欧美一级毛片免费观看 | 日本黄色不卡视频 | 亚洲国产看片 | 欧美午夜精品久久久久久浪潮 | 亚洲精品久久久久久久久久久久久 | 日日操夜夜操视频 | 97热在线 | 韩日在线 | 中文字幕1区 | 精品久久久久久久 | 久久久激情视频 | 国产精品av久久久久久毛片 | 久久国产视频网站 | 国产亚洲精品精品国产亚洲综合 | 91精品久久 | 神马影院一区二区三区 | 免费欧美| 成人免费视频网站在线观看 | 91素人|