1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
JSONObject obj = new JSONObject(input);
String endDate = obj.getString("DateEnd");
// ==> /Date(1407119352000)/
// On conserve le contenu entre paranthèse pour le transformer en type "long"
StringTokenizer st = new StringTokenizer(endDate, "()");
List<Object> list = new ArrayList<Object>();
while (st.hasMoreElements()) {
list.add(st.nextElement());
}
String temp = (String)list.get(1);
long dateToConvert = Long.parseLong(temp);
Format format = new SimpleDateFormat("dd.MM.yyyy à HH:mm");
String dateToPrint = format.format(dateToConvert);
this.collection.put("endDate", dateToPrint); |