久久久久久久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:獲取當前星期幾的值)
主站蜘蛛池模板: 久久伊人精品 | 99在线免费观看视频 | 国产一区二区三区四区hd | 一区二区三区回区在观看免费视频 | 天天综合干| 国产亚洲人成a在线v网站 | 欧美一区二区三区高清视频 | 特级毛片www | 成人毛片一区二区三区 | 欧美 日韩 视频 | aaa在线观看 | 国产精品一二三区 | av在线免费观看网站 | 久久精品国产免费一区二区三区 | 一区二区三区欧美在线 | 99福利视频| 91视频a| 亚洲国产一区二区视频 | 欧美日日 | www.成人.com| 国产精品久久久久久妇女6080 | 亚洲精品一区av在线播放 | 免费电影av | 日本欧美大片 | 色综合久久久久 | 视频在线一区二区 | 免费在线成人 | 亚洲精品电影在线观看 | 亚洲高清视频在线 | 久久午夜精品 | 成人激情免费视频 | 日韩一区二区在线看 | 国产精品不卡一区二区三区 | 欧美色综合网 | 日韩一区二区三区精品 | 性生生活大片免费看视频 | 色资源在线| 成人高清在线 | 欧美久久久电影 | 欧美成人专区 | 日韩高清成人 |