从 org.joda.time.DateTime 转换为 java.util.Calendar 的方法

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/363930/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 13:51:40  来源:igfitidea点击:

Approach to convert from org.joda.time.DateTime to java.util.Calendar

javadatetimejodatime

提问by

Anyone done this and can share? I see an option or two but want to know what others have accomplished.

有谁做过这个并且可以分享吗?我看到了一两个选项,但想知道其他人取得了什么成就。

回答by Esko

According to joda-time documentation the preferred method to use is to call this: AbstractDateTime#toCalendar.

根据 joda-time 文档,首选使用的方法是调用: AbstractDateTime#toCalendar

回答by Carlos D. Garza

in the 2.1 you can use

在 2.1 你可以使用

public static Calendar parseCalendar(DateTime dt){
    return dt.toGregorianCalendar();
}