我在java.util.Date類型的Google DataStore中使用new()日期保存Entitiy,然後將其獲取到Android客戶端,並以此格式獲取它:日期序列化Google Cloud Endpoint
yyyy-MM-dd'T'HH:mm:ss.SSS'Z'
example: '2015-12-27T09:49:51.013Z'
我保存日期在Android客戶端共享偏好在串用這種方法:
.getDate().toStringRfc3339()
後來的後來,當我需要它發送到服務器,我嘗試設置的日期實體以這種方式:
.setDate(stringDateInServerFormatToDate(date));
public com.google.api.client.util.DateTime stringDateInServerFormatToDate(String dateInServerFormat){
googleDate = new com.google.api.client.util.DateTime(dateInServerFormat);
return googleDate;
}
而且這樣的作品,但是當我試圖把它放在終點在服務器上,我得到這個錯誤:
"message": "com.google.appengine.repackaged.org.codehaus.jackson.map.JsonMappingException: Can not construct instance of int from String value '2015-12-27T09:49:51.013Z': not a valid Integer value\n at [Source: N/A; line: -1, column: -1] (through reference chain: com.imaginamos.caapturesupervisor.backend.Entities.User[\"userUpdate\"])"
我已經嘗試了許多fromas並沒有成功。 我該如何解決這個問題?
Hi @dbort我也在開發de Endpoint,你使用com.google.api.server.spi.types.DateAndTime嗎?你可以向我展示這種類型的實例,在服務器和客戶端實現,解析它,thx! –
我在我的答案中添加了更多信息;看看,讓我知道如果它幫助! – dbort
謝謝,我會遲到如果爲我工作,那麼我會接受答案 –