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

Java 日歷總是顯示相同的時間

Java Calendar always shows the same time(Java 日歷總是顯示相同的時間)
本文介紹了Java 日歷總是顯示相同的時間的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

限時送ChatGPT賬號..

下面是我的代碼.

public class TestCalendar {

public static void main(String[] args){
    int unique_id = Integer.parseInt("" + Calendar.HOUR + Calendar.MINUTE
            + Calendar.SECOND);

    System.out.println(unique_id);
}
}

Calendar.HOUR 應(yīng)該給我

Calendar.HOUR is supposed to give me

public static final int HOUR 用于獲取和設(shè)置的字段編號,指示早上的時間或下午.HOUR 用于 12 小時制 (0 - 11).中午和午夜用 0 表示,而不是到 12 點(diǎn).例如,在晚上 10:04:15.250,HOUR 是 10.

public static final int HOUR Field number for get and set indicating the hour of the morning or afternoon. HOUR is used for the 12-hour clock (0 - 11). Noon and midnight are represented by 0, not by 12. E.g., at 10:04:15.250 PM the HOUR is 10.

無論我運(yùn)行多少次代碼,它總是給我相同的 unique_id.(101213),我機(jī)器上的當(dāng)?shù)貢r間是下午 1:30.我在這里做錯了什么?

It doesnt matter how many times I run this code, it always gives me the same unique_id. (101213) and my local time on my machine is 1:30pm. What am I doing wrong here?

謝謝.

推薦答案

您的代碼只是連接常量,Calendar 定義這些常量以識別其中的一些字段.要獲取這些字段的值,請調(diào)用 Calendar.get() 并將常量標(biāo)識符作為參數(shù)傳遞:

Your code is just concatenating constants, that the Calendar defines to identify some of it's fields. To get values of these fields, call Calendar.get() and pass the constant identifier as an argument:

public class TestCalendar {

public static void main(String[] args){
    Calendar c = Calendar.getInstance();
    int unique_id = Integer.parseInt("" + c.get(Calendar.HOUR) + c.get(Calendar.MINUTE)
            + c.get(Calendar.SECOND));

    System.out.println(unique_id);
}
}

上述方法可行,但結(jié)果與唯一 ID 相差甚遠(yuǎn).要獲得唯一標(biāo)識時間點(diǎn)的 ID(精度為毫秒),請考慮 Calendar.getTimeInMillis().

The above would work, but the result will be far from unique ID. To get an ID uniquely identifying a point in time (with the precision of milliseconds), consider Calendar.getTimeInMillis().

這篇關(guān)于Java 日歷總是顯示相同的時間的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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)前星期幾的值)
主站蜘蛛池模板: 一区二区三区视频在线 | 久久三级av| 精品国产一区二区 | 三级在线免费 | a级黄色毛片免费播放视频 国产精品视频在线观看 | 欧美激情久久久 | 国产激情在线播放 | 999国产视频| 国产色网站 | 久草网在线视频 | 婷婷久久网| 亚洲国产自产 | 美女亚洲一区 | 91免费观看 | 免费国产一区二区 | 一区二区三区高清 | 亚洲精品欧美 | 亚洲国产一区二区视频 | 色伊人久久| 午夜视频免费在线观看 | 狠狠色综合久久丁香婷婷 | 日韩在线精品视频 | 蜜桃免费一区二区三区 | 国产毛片久久久久久久久春天 | 色欧美综合 | 欧美精品一区二区三区一线天视频 | 97在线观看 | 成人福利网站 | 欧美区日韩区 | 国产精品久久久久久久久久久久 | 国产在线精品一区二区 | 热re99久久精品国99热观看 | 91精品久久久久久久久中文字幕 | 成人免费看黄网站在线观看 | 视频精品一区二区三区 | 欧美一区二区三区久久精品 | 欧美日韩国产一区二区三区 | 欧美一区二区三区四区视频 | 日韩精品一区二区三区在线播放 | 在线观看毛片网站 | 久久一区二区三区四区五区 |