我想将Google DateTime
转换为org.joda.time.DateTime
。不兼容的类型:com.google.api.client.util.DateTime无法转换为org.joda.time.DateTime
这是Google实施的代码。
我如何能实现呢?
我想将Google DateTime
转换为org.joda.time.DateTime
。不兼容的类型:com.google.api.client.util.DateTime无法转换为org.joda.time.DateTime
这是Google实施的代码。
我如何能实现呢?
返回日期/时间值表示为自Unix纪元的毫秒数。 如果指定时区,则此值将标准化为UTC,因此要格式化此日期/时间值,必须应用时区转换。
公开日期时间(长瞬间)
构建一个实例从1970-01-01T00设置到毫秒:00:00Z使用ISOChronology默认时区。
// getValue() return millis since epoch
long millis = googleDate.getValue();
// Which is accepted by Joda DateTime's constructor
DateTime jodaDate = new DateTime(millis);
我测试了它,但我得到空。可能问题在别的地方。 –
'getValue()'返回一个原始'long'。它不能为空。 – Stewart
也许已经太晚了,不过我已经解决了一个非常类似的问题如下
//Let's suppose date is our google DateTime
org.joda.time.DateTime jodaDate = date.getDateTime(date.getValue);
这从谷歌DateTime是否长期价值
创建一个新的乔达日期时间
通过'java.util.Date'? – Stewart
请参阅[此答案](http://stackoverflow.com/a/21724350/1314743)。 –
@Stewart你能告诉我代码示例吗? –