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

克隆 GregorianCalendar 的最快方法是什么?

Quickest way to clone a GregorianCalendar?(克隆 GregorianCalendar 的最快方法是什么?)
本文介紹了克隆 GregorianCalendar 的最快方法是什么?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

限時(shí)送ChatGPT賬號(hào)..

我正在嘗試制作一個(gè)對(duì)象的深層副本,包括一個(gè) GregorianCalendar 實(shí)例.我總是對(duì)使用 clone() 持謹(jǐn)慎態(tài)度,而且這里似乎沒(méi)有被覆蓋,所以我只是逐個(gè)字段地進(jìn)行復(fù)制.理想情況下,會(huì)有一個(gè)復(fù)制構(gòu)造函數(shù),我可以像這樣使用它:

I'm trying to make a deep copy of an object, including a GregorianCalendar instance. I'm always wary of using clone() and it doesn't seem to have been overridden here, so I'm just doing the copy field by field. Ideally, there'd be a copy constructor, which I could use like so:

GregorianCalendar newCalendar = new GregorianCalendar(oldCalendar);

不幸的是,我在 API 中找不到任何此類(lèi)功能,并且一直在試圖找出我需要哪些字段才能獲得準(zhǔn)確的副本.那么,要復(fù)制其中一個(gè)日歷,你會(huì)怎么做呢?我在這里錯(cuò)過(guò)了一些簡(jiǎn)單的快捷方式嗎?

Unfortunately I can't find any such functionality in the API and am stuck trying to figure out which fields I need to get an exact copy. So, to make a copy of one of these calendars, how would you do it? Am I missing some simple shortcut here?

推薦答案

java.util.Calendar 已經(jīng)覆蓋了正在工作的 clone(),所以使用它.此外,Calendar 沒(méi)有很深的數(shù)據(jù)層次——它的數(shù)據(jù)主要是 ints.

java.util.Calendar has overridden clone() which is working, so use it. Furthermore, Calendar doesn't have a deep data hierarchy — its data are mainly ints.

要擴(kuò)展答案,您可以調(diào)用 SerializationUtils.clone(...) (來(lái)自 Apache commons-lang)在任何進(jìn)行深拷貝的對(duì)象上,如果整個(gè)數(shù)據(jù)層次結(jié)構(gòu)實(shí)現(xiàn) Serializable.

To extend the answer, you can call SerializationUtils.clone(…) (from Apache commons-lang) on any object which makes a deep copy, if the whole data hierarchy implements Serializable.

這篇關(guān)于克隆 GregorianCalendar 的最快方法是什么?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

Parsing an ISO 8601 string local date-time as if in UTC(解析 ISO 8601 字符串本地日期時(shí)間,就像在 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)前星期幾的值)
主站蜘蛛池模板: 瑟瑟免费视频 | 精国产品一区二区三区 | 国产一区二区三区 | 亚洲毛片| 久久精品中文字幕 | 色婷婷综合久久久中字幕精品久久 | 欧美一级高清片 | 国产精品视频一二三区 | 国产中文一区二区三区 | 91夜色在线观看 | 欧美激情国产精品 | 中国免费黄色片 | 免费黄色的视频 | 亚洲欧美中文日韩在线v日本 | k8久久久一区二区三区 | 日韩在线 | 又黄又爽的网站 | 国产视频中文字幕 | 日韩在线精品视频 | 欧美高清视频一区 | 欧美美女爱爱 | 国产综合久久 | 视频羞羞| 久久里面有精品 | 伊人网99 | 日韩av成人在线 | 偷拍自拍第一页 | 国产精品视频免费观看 | 中文字幕在线视频精品 | 日韩免费视频 | 日韩在线观看网站 | 五月婷亚洲 | 国产一区二区三区四区三区四 | 亚洲精品乱码久久久久久蜜桃 | 一区欧美 | 国产精品免费一区二区三区 | 免费一级片 | 亚洲精品一区在线观看 | 免费看啪啪网站 | 成人三区四区 | 国产视频福利一区 |