Java: Send Date Object as JSONObject through Parse.com REST API

回眸只為那壹抹淺笑 提交于 2019-12-05 07:12:34

Your format doesn't match the one they've required. For example:

Theirs: 2011-08-21T18:02:52.249Z
Yours:  2011-08-21 18:02:52.249

You're missing the T and the Z.

So try changing your format to:

SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");

To be honest, I'd be surprised if this weren't handled automatically though - have you tried just dateAsObj.put("iso", sendTime)?

Girish Sharma

Standard Date Object is not stored in Parse. You have to set it as a JSON Object with "__type": "Date" and "iso": Date_String_you_want_to_set. with the date string formatted as below:

DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!