[英]Incompatible types: com.google.api.client.util.DateTime cannot be converted to org.joda.time.DateTime
I want to convert Google DateTime
into org.joda.time.DateTime
.我想将 Google
DateTime
转换为org.joda.time.DateTime
。
This is the code of Google's implementation.这是谷歌的实现代码。
http://grepcode.com/file/repo1.maven.org/maven2/com.google.http-client/google-http-client/1.15.0-rc/com/google/api/client/util/DateTime.java http://grepcode.com/file/repo1.maven.org/maven2/com.google.http-client/google-http-client/1.15.0-rc/com/google/api/client/util/DateTime。爪哇
How I can implement this?我该如何实施?
Returns the date/time value expressed as the number of milliseconds since the Unix epoch.
返回日期/时间值,表示为自 Unix 纪元以来的毫秒数。 If the time zone is specified, this value is normalized to UTC, so to format this date/time value, the time zone shift has to be applied.
如果指定了时区,则此值将标准化为 UTC,因此要格式化此日期/时间值,必须应用时区偏移。
public DateTime(long instant)
公共日期时间(长瞬间)
Constructs an instance set to the milliseconds from 1970-01-01T00:00:00Z using ISOChronology in the default time zone.
在默认时区中使用 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);
Probably it is too late, but I have just solve a quite similar problem as follows可能为时已晚,但我刚刚解决了一个非常相似的问题,如下所示
//Let's suppose date is our google DateTime
org.joda.time.DateTime jodaDate = date.getDateTime(date.getValue);
This creates a new joda DateTime from the google DateTimes' long value这会从 google DateTimes 的 long 值创建一个新的 joda DateTime
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.