My API gives this result:
{ "Posts": [{ "UseName": "Robert Ray", "DateTime": "\/Date(1376841597000)\/", "PostText": "Welcome!!\u003cbr\u003eThis Is my Text" }] }
I am parsing my JSON Like This
try { Posts = json.getJSONArray(TAG_POSTS); for(int i = 0; i < Posts.length(); i++){ JSONObject c = Posts.getJSONObject(i); String post_text = c.getString("PostText"); String strDate = "2013-05-15T10:00:00-0700"; SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm"); Date date = (Date) dateFormat.parse(c.getString("DateTime")); } } catch (JSONException e) {
But it does not work, I want it to calculate the time elapsed since the moment the User posted the message, i.e. we need to subtract the current date with date in JSON and then convert it to minute / hour
source share