如何将 org.joda.time.LocalDateTime 转换为 java.Util.Calendar?
How do I convert a org.joda.time.LocalDateTime into java.Util.Calendar?
问题真的在标题里。最简单的方法是什么?
您可以使用 toCalendar
这里是postApproach to convert from org.joda.time.DateTime to java.util.Calendar
例如
Date date = dateTime.toDate();
Calendar calendar = dateTime.toCalendar(Locale.getDefault());
LocalDateTime jodaTime = LocalDateTime.now();
Calendar cal = Calendar.getInstance();
cal.setTime(jodaTime.toDate());
也许你可以试试这个方法,LocalDateTime to Calendar of java.util:
转换顺序:LocalDateTime -> DateTime -> Calendar
LocalDateTime ldt = new LocalDateTime();
DateTime dt = ldt.toDateTime();
Calendar c = dt.toCalendar(null);
System.out.println(c.getTime());
希望这个对你有用。干杯!
问题真的在标题里。最简单的方法是什么?
您可以使用 toCalendar
这里是postApproach to convert from org.joda.time.DateTime to java.util.Calendar
例如
Date date = dateTime.toDate();
Calendar calendar = dateTime.toCalendar(Locale.getDefault());
LocalDateTime jodaTime = LocalDateTime.now();
Calendar cal = Calendar.getInstance();
cal.setTime(jodaTime.toDate());
也许你可以试试这个方法,LocalDateTime to Calendar of java.util:
转换顺序:LocalDateTime -> DateTime -> Calendar
LocalDateTime ldt = new LocalDateTime();
DateTime dt = ldt.toDateTime();
Calendar c = dt.toCalendar(null);
System.out.println(c.getTime());
希望这个对你有用。干杯!