44
我想在執行一些更多的計算之前簡單地將TimeZone信息添加回LocalDate。 LocalDate來自於使用ObjectLab LocalDateCalculator將日期添加到現有DateTime,但該方法需要返回修改後的ReadableInstant以形成一個Interval,然後我可以檢查它。如何把Joda Localdate轉換爲Joda DateTime?
我想達喬達的LOCALDATE到喬達日期時間轉換的代碼:
LocalDate contextLocalBusinessDate = calculator.getCurrentBusinessDate();
DateTime businessDateAsInContextLocation = new DateTime(contextLocalBusinessDate, contextTimeZone);
我得到的錯誤是從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)
我在尋找解決此問題的方法或解決方案,該方法會導致帶有完整時區信息的精確時間間隔。
現貨。有一點需要注意:toDateTimeAtStartOfDay並不意味着「午夜」...有些時區實施夏令時更改,以便從午夜到凌晨1點跳過。 – 2011-01-11 10:28:31