Sim*_*bbs 51 java timezone jodatime
我想在执行更多计算之前简单地将TimeZone信息添加回LocalDate.LocalDate来自使用ObjectLab LocalDateCalculator为现有DateTime添加天数,但该方法需要返回一个修改后的ReadableInstant以形成一个Interval,然后我可以检查它.
我正在尝试的代码相当于将Joda LocalDate转换为Joda DateTime:
LocalDate contextLocalBusinessDate = calculator.getCurrentBusinessDate();
DateTime businessDateAsInContextLocation = new DateTime(contextLocalBusinessDate, contextTimeZone);
Run Code Online (Sandbox Code Playgroud)
我得到的错误来自Joda的转换系统:
java.lang.IllegalArgumentException: No instant converter found for type: org.joda.time.LocalDate
at org.joda.time.convert.ConverterManager.getInstantConverter(ConverterManager.java:165)
at org.joda.time.base.BaseDateTime.<init>(BaseDateTime.java:147)
at org.joda.time.DateTime.<init>(DateTime.java:192)
Run Code Online (Sandbox Code Playgroud)
我正在寻找一个解决此问题的方法,或者一种解决方法,可以获得具有完整时区信息的准确间隔.
ska*_*man 73
有各种方法LocalDate,包括:
LocalDate::toDateTimeAtCurrentTime()LocalDate::toDateTimeAtStartOfDay()LocalDate::toDateTime( LocalTime )LocalDate::toDateTime( LocalTime , DateTimeZone )你必须明确你希望时间组件在结果DateTime对象中的位置,这就是为什么DateTime通用转换构造函数不能这样做的原因.