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

按時區(qū)轉(zhuǎn)換日期

Convert Date by TimeZone(按時區(qū)轉(zhuǎn)換日期)
本文介紹了按時區(qū)轉(zhuǎn)換日期的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

在上面的代碼中,我想將服務器的時區(qū) (GMT-02:00) 的日期轉(zhuǎn)換為我的設備 (GMT-03:00) 的時區(qū).但我總是有相同的服務器日期.我做錯了什么?

In that code above I want to transform a Date by the TimeZone of Server (GMT-02:00) to TimeZone from my Device (GMT-03:00). But I Always have the same Date of the server. What I doing wrong?

時區(qū) timeZoneServer = TimeZone.getTimeZone(timeZoneServerString);長時間 = new Long(Long.valueOf(timeInMilis));

TimeZone timeZoneServer = TimeZone.getTimeZone(timeZoneServerString); Long time = new Long(Long.valueOf(timeInMilis));

        Calendar calendarDateServer =   Calendar.getInstance(timeZoneServer);
        calendarDateServer.setTimeInMillis(time);
        long miliServer = calendarDateServer.getTimeInMillis();

        TimeZone timeZoneMeu = TimeZone.getDefault();
        Calendar meuCalendario =  new GregorianCalendar();
        meuCalendario.setTimeZone(timeZoneMeu);

        meuCalendario.setTimeInMillis(miliServer);  
        Date transformedDate = meuCalendario.getTime();


        return transformedDate; 

推薦答案

我做錯了什么?

您假設 Date 有一個時區(qū)作為開始.它沒有.Calendar 可以,但 Date 自 Unix 紀元以來只有 毫秒.它不知道日歷系統(tǒng)或時區(qū).這只是一個時間點.

You're assuming that a Date has a time zone to start with. It doesn't. A Calendar does, but a Date is just milliseconds since the Unix epoch. It doesn't know about calendar systems or time zones. It's just a point in time.

不清楚你想對結(jié)果做什么 - 但如果它是格式化顯示的問題,只需使用 SimpleDateFormat 并在 that 上設置時區(qū)而是.

It's not clear what you want to do with the result - but if it's a matter of formatting it for display, just use SimpleDateFormat and set the time zone on that instead.

我還強烈建議您使用 Joda Time 而不是內(nèi)置類型...這是一個更明智的 API.

I would also strongly recommend that you use Joda Time instead of the built-in types... it's a much more sensible API.

這篇關(guān)于按時區(qū)轉(zhuǎn)換日期的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

Parsing an ISO 8601 string local date-time as if in UTC(解析 ISO 8601 字符串本地日期時間,就像在 UTC 中一樣)
How to convert Gregorian string to Gregorian Calendar?(如何將公歷字符串轉(zhuǎn)換為公歷?)
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 日之前日期的日歷到日期轉(zhuǎn)換.公歷到儒略歷切換)
java Calendar setFirstDayOfWeek not working(java日歷setFirstDayOfWeek不起作用)
Java: getting current Day of the Week value(Java:獲取當前星期幾的值)
主站蜘蛛池模板: 亚洲男人天堂2024 | 久久精品一区 | av一级在线观看 | 日韩欧美成人精品 | 中文字幕在线一区 | 亚洲精品一区在线 | 亚洲毛片在线观看 | 亚洲国产小视频 | 亚洲91精品 | 一区二区精品视频 | 亚洲欧美中文日韩在线v日本 | 99爱免费| 国产精品综合视频 | 欧美白人做受xxxx视频 | 狠狠操狠狠搞 | 欧美一区二区在线视频 | 亚洲欧美在线一区 | 国产亚洲一区精品 | 亚洲免费在线 | 久久国产精品99久久久大便 | 在线观看免费av网站 | 亚洲视频在线一区 | 九九国产| 黄色网址在线免费播放 | 91精品久久久久 | 国产免费一区 | 小草久久久久久久久爱六 | 男人的天堂久久 | 久久这里只有精品首页 | 天天艹天天干天天 | jvid精品资源在线观看 | 欧美一级小视频 | 精品视频一区二区三区 | 国产精品一区二区在线播放 | 羞羞视频网站 | 国产精品久久久久久久久久东京 | 国产精品国产精品国产专区不卡 | 国产美女自拍视频 | 精久久久久 | 热久久久久 | 婷婷丁香在线视频 |