Salve a tutti come da titolo ho problemi a fare il toString di un json array, ho una Calendar che mi piacerebbe stampare in maniera corretta cioè come faccio nella sua classe :
codice:
java.util.Date utilDate = this.getDataOra().getTime();
DateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
String data = df.format(utilDate);
Il codice invece Json è il seguente :
codice:
public Representation visualizza() throws DAOException, JSONException {
JSONArray ja = new JSONArray();
DAODinamico dao = new DAODinamico();
List<Registrazione> listaRegistrazioni = dao.doSelect();
for (Object u : listaRegistrazioni) {
JSONObject obj = new JSONObject();
Registrazione r = (Registrazione) u;
obj.put("data ed ora", r.getDataOra());
obj.put("cpuSis", r.getCpuSis());
obj.put("memUsed", r.getMemUso());
obj.put("core1", r.getCore1());
obj.put("core2", r.getCore2());
obj.put("core3", r.getCore3());
obj.put("core4", r.getCore4());
obj.put("MbTx", r.getByteRx());
obj.put("MbRx", r.getByteTx());
ja.put(obj);
}
return new JsonRepresentation(ja.toString());
}
i dao mi gestiscono la persistenza e fanno le insert e le select sul db, devo esporre questi dati tramite jSon, dovrei fare l'override del metodo toString() di json Array ma mi continua a stampare il calendar nel classico modo "brutto" senza esser formattato
Ringrazio in anticipo per una risposta