我想將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你能告訴我代碼示例嗎? –