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

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

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

問題描述

限時送ChatGPT賬號..

我正在嘗試制作一個對象的深層副本,包括一個 GregorianCalendar 實例.我總是對使用 clone() 持謹慎態(tài)度,而且這里似乎沒有被覆蓋,所以我只是逐個字段地進行復制.理想情況下,會有一個復制構(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 中找不到任何此類功能,并且一直在試圖找出我需要哪些字段才能獲得準確的副本.那么,要復制其中一個日歷,你會怎么做呢?我在這里錯過了一些簡單的快捷方式嗎?

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 沒有很深的數(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.

要擴展答案,您可以調(diào)用 SerializationUtils.clone(...) (來自 Apache commons-lang)在任何進行深拷貝的對象上,如果整個數(shù)據(jù)層次結(jié)構(gòu)實現(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 的最快方法是什么?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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:獲取當前星期幾的值)
主站蜘蛛池模板: 黄色av网站免费看 | 91视频免费在观看 | 亚洲一区视频在线 | 国产精品久久久久9999鸭 | 老外黄色一级片 | 精品一区二区电影 | 91在线电影 | 成人在线视频免费观看 | 日韩在线精品视频 | 综合久久综合久久 | 亚洲视频在线观看 | 久久精品日产第一区二区三区 | 国产精品1 | 国产成人精品久久久 | 国产欧美精品区一区二区三区 | 免费看黄色国产 | 日韩成人一区 | av无遮挡 | 国产成人精品免费视频 | 国产午夜精品一区二区三区四区 | 午夜视频在线观看网址 | japanhd成人| 亚洲视频一区在线观看 | 欧一区二区 | 夜夜操操操| 国产在线精品一区二区 | 欧美日韩精品区 | 久在线观看 | 日韩成人高清在线 | 日韩久草 | 国产精品久久久久久久免费大片 | a毛片 | 久久网站黄| 日本视频在线播放 | 蜜桃黄网 | www国产精品 | 九色 在线 | 欧美人人| 国内精品视频在线观看 | 日韩电影一区二区三区 | 欧美日韩视频在线第一区 |