久久久久久久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国内产香蕉| 日韩色视频 | 日本一本在线 | 国产精品免费看 | 亚洲精品在线免费观看视频 | 成人午夜在线 | 久久婷婷国产麻豆91 | 国产成人精品久久二区二区 | 国产一区二区自拍 | 九九视频在线观看 | 国产福利在线 | 一区二区三区中文字幕 | 黑人巨大精品欧美一区二区免费 | 久久综合婷婷 | 色综合久久久久 | 午夜私人影院在线观看 | 99久久精品免费看国产四区 | 日韩成人久久 | 午夜天堂精品久久久久 | 亚洲一区二区在线播放 | 99热精品久久 | 中文字字幕一区二区三区四区五区 | 日韩一级欧美一级 | 久久亚洲精品久久国产一区二区 | 色www精品视频在线观看 | 久久久久亚洲视频 | 亚洲成人一区二区三区 | 欧美在线一区二区三区 | 夜夜艹天天干 | 一级毛片免费视频观看 | 国产一区二区三区免费 | 欧美理论片在线观看 | 国产传媒视频在线观看 | 999国产精品视频免费 | 日韩在线精品 | 在线观看中文字幕视频 | 中文字幕在线免费视频 | 久久精品视频在线观看 | 亚洲成人精品 | 国产成人综合在线 | 91在线视频国产 |