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

Java 日歷設(shè)置不正確

Java Calendar Setting Incorrectly(Java 日歷設(shè)置不正確)
本文介紹了Java 日歷設(shè)置不正確的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

限時送ChatGPT賬號..

我在使用 Java 的日歷時遇到了一些問題.我正在解析 txt 文件中的一些數(shù)據(jù),并且需要創(chuàng)建一個日期.完成以下代碼后:

I'm having some trouble with Java's Calendar. I'm parsing some data from a txt file, and need to create a date. After completion of the following code:

tmpYear = Double.parseDouble(row[yearIndex]);
tmpMonth = Double.parseDouble(row[monthIndex]);
tmpDay = Double.parseDouble(row[dayIndex]);
if(timeIndex != -1)
    tmpTime = Double.parseDouble(row[timeIndex]);
if(secondsIndex != -1)
    tmpSeconds = Double.parseDouble(row[secondsIndex]);

我可以調(diào)試一下,看到變量如下:tmpYear == 2010
tmpMonth == 12
tmpDay == 30
tmpTime == 15(這是一天中的小時)
tmpSeconds == 0

I can debug and see that the variables are as follows: tmpYear == 2010
tmpMonth == 12
tmpDay == 30
tmpTime == 15 (This is the hour of the day)
tmpSeconds == 0

但是在運(yùn)行以下代碼時:

But when running the following code:

cal.set((int)tmpYear,(int)tmpMonth,(int)tmpDay,(int)tmpTime,
            (int)((tmpTime - (int)tmpTime)*100),(int)tmpSeconds);
System.out.println(cal.getTime().toString());

我得到這個是為了輸出:
2011 年 1 月 30 日星期日 15:00:00 CST

I'm getting this for an output:
Sun Jan 30 15:00:00 CST 2011

有人能解釋一下這可能是什么原因嗎?提前感謝大家的幫助!

Can someone explain what a possible reason for this would be? Thank you all in advance for the help!

推薦答案

月份索引為 0-11 而不是 1-12.
0 = 一月
1 = 二月
...
11 = 十二月
請改用 tmpMonth = value -1.

months are indexed 0-11 instead of 1-12.
0 = January
1 = February
...
11 = December
Use tmpMonth = value -1 instead.

這篇關(guān)于Java 日歷設(shè)置不正確的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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:獲取當(dāng)前星期幾的值)
主站蜘蛛池模板: 色在线视频网站 | 日本黄色影片在线观看 | 国产精品jizz在线观看老狼 | 国产精品夜夜夜一区二区三区尤 | 一级免费毛片 | 99精品欧美一区二区三区 | 午夜看片 | 亚洲国产精品99久久久久久久久 | 久久精品国产一区二区三区不卡 | 好婷婷网 | 亚洲国产成人精品一区二区 | 婷婷五月色综合香五月 | 日韩伦理一区二区 | 成年女人免费v片 | 91免费观看视频 | 免费黄色av| 秋霞精品| 欧美久操网 | 日韩欧美二区 | 夜夜爽99久久国产综合精品女不卡 | 国产精品久久久久久久岛一牛影视 | 亚洲精品一区在线观看 | 国产一区视频在线 | 97成人免费| 久久久久久免费毛片精品 | 久久亚洲欧美日韩精品专区 | 亚洲一区二区av在线 | 中文字幕免费 | 久久一区二区三区免费 | av黄色免费在线观看 | 国产精品极品美女在线观看免费 | caoporn国产精品免费公开 | 亚洲日韩中文字幕一区 | 国产成人99久久亚洲综合精品 | 欧美成人精品激情在线观看 | 成人在线免费观看 | 精精国产xxxx视频在线 | 日韩中文字幕 | 久久精品成人一区 | 久久国产精品久久久久久久久久 | 日韩欧美在线观看 |