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

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

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

問題描述

限時送ChatGPT賬號..

我正在嘗試制作一個對象的深層副本,包括一個 GregorianCalendar 實例.我總是對使用 clone() 持謹慎態度,而且這里似乎沒有被覆蓋,所以我只是逐個字段地進行復制.理想情況下,會有一個復制構造函數,我可以像這樣使用它:

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 已經覆蓋了正在工作的 clone(),所以使用它.此外,Calendar 沒有很深的數據層次——它的數據主要是 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.

要擴展答案,您可以調用 SerializationUtils.clone(...) (來自 Apache commons-lang)在任何進行深拷貝的對象上,如果整個數據層次結構實現 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.

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

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

相關文檔推薦

Parsing an ISO 8601 string local date-time as if in UTC(解析 ISO 8601 字符串本地日期時間,就像在 UTC 中一樣)
How to convert Gregorian string to Gregorian Calendar?(如何將公歷字符串轉換為公歷?)
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 日之前日期的日歷到日期轉換.公歷到儒略歷切換)
java Calendar setFirstDayOfWeek not working(java日歷setFirstDayOfWeek不起作用)
Java: getting current Day of the Week value(Java:獲取當前星期幾的值)
主站蜘蛛池模板: 在线观看国产黄色 | 午夜久久久久久 | 欧美视频久久 | 成年人视频网站 | 久久婷婷色 | 国产黄色av | 久草国产视频 | 国产精品福利视频 | 九九热在线精品 | 欧美一区二区三区的 | 人人爽视频 | 国产伦精品一区二区三区四区 | 成人做爰免费视频免费看 | 一区二区三区在线观看视频 | 福利在线播放 | 久久精品导航 | 一区二区三区四区视频 | 国产一区二区久久 | av色婷婷 | 三级在线看 | 欧美综合一区 | 亚洲视频在线观看 | 在线视频日本 | 午夜精品久久久久久久 | 中文字幕在线免费观看视频 | 亚洲精品日韩丝袜精品 | 日韩天堂网 | 国产精品国产三级国产 | 怡红院亚洲| 国产精品无遮挡 | 夜夜嗨av一区二区三区 | 欧美影院一区 | 伊人精品在线 | 一级片在线观看视频 | 久久精品一区二区国产 | 精品国产三级 | 日韩欧美国产成人 | a级片网站 | 国产在线一区二区三区 | 欧美精品在线播放 | 国产一区精品视频 |