I would like the JSON output to be in a particular date format. My JSON output is:
"data":[[{"id":1,"createTimestamp":{"iMillis":1431463708237,"iChronology":{"iBase":{"iMinDaysInFirstWeek":4}}},"startTimestamp":{"iMillis":1420092000000,"iChronology":{"iBase":{"iMinDaysInFirstWeek":4}}},"endTimestamp":{"iMillis":1451541600000,"iChronology":{"iBase":{"iMinDaysInFirstWeek":4}}}}]]
But I would like the timestamps to be in this format:
2015-05-12T20:48:28.237Z
My code:
JSONArray a = new JSONArray();
a.add(aList);
JSONObject j = new JSONObject();
j.put("data", a);
JsonArray array = new JSONArray();
array.add(j);
String jason = gson.toJson(array);
I tried something like this, but not working
for (Noti n : aList) {
DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
dtf.parseDateTime(n.getCreateTimestamp().toString());
}
Thanks
In the JS/Jquery, I used