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

后端 未结 3 1420
攒了一身酷
攒了一身酷 2021-01-01 12:08

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

相关标签:
3条回答
  • 2021-01-01 12:40

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

    0 讨论(0)
  • 2021-01-01 12:41

    in the 2.1 you can use

    public static Calendar parseCalendar(DateTime dt){
        return dt.toGregorianCalendar();
    }
    
    0 讨论(0)
  • 2021-01-01 12:53

    You can also call AbstractInstant#toDate

    http://joda-time.sourceforge.net/api-release/org/joda/time/base/AbstractInstant.html#toDate()

    0 讨论(0)
提交回复
热议问题