![](/img/trans.png)
[英]Found: 'java.util.Date', required: 'com.google.api.client.util.DateTime' GAE
[英]Incompatible types: com.google.api.client.util.DateTime cannot be converted to org.joda.time.DateTime
我想将 Google DateTime
转换为org.joda.time.DateTime
。
这是谷歌的实现代码。
我该如何实施?
返回日期/时间值,表示为自 Unix 纪元以来的毫秒数。 如果指定了时区,则此值将标准化为 UTC,因此要格式化此日期/时间值,必须应用时区偏移。
公共日期时间(长瞬间)
在默认时区中使用 ISOChronology 构造一个设置为 1970-01-01T00:00:00Z 毫秒的实例。
// getValue() return millis since epoch
long millis = googleDate.getValue();
// Which is accepted by Joda DateTime's constructor
DateTime jodaDate = new DateTime(millis);
可能为时已晚,但我刚刚解决了一个非常相似的问题,如下所示
//Let's suppose date is our google DateTime
org.joda.time.DateTime jodaDate = date.getDateTime(date.getValue);
这会从 google DateTimes 的 long 值创建一个新的 joda DateTime
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.