I'm working on CodeName One and I've got this error while retrieving data from the database.
The problem is with the element with type date the json response is working well and other attributes are displayed successfully.
Here's my code and I hope that someone could help me. Thank you in advance.
private Concour parseConcours(Map<String, Object> map) {
Concour c = new Concour();
c.setId(((Double) map.get("id")).intValue());
c.setSujet(map.get("sujet").toString());
c.setNom(map.get("nom").toString());
c.setImageName(map.get("imageName").toString());
c.setDescription(map.get("description").toString());
c.setCategorie(map.get("categorie").toString());
c.setCouleur(map.get("couleur").toString());
c.setDateDebut(new Date((((Double) ((Map<String, Object>) map.get("dateDebut")).get("timestamp")).longValue() * 1000)));
c.setDateFin(new Date((((Double) ((Map<String, Object>) map.get("dateFin")).get("timestamp")).longValue() * 1000)));
return c;
}
try this :
try {
Date date1 = new SimpleDateFormat("yyyy-MM-dd").parse(sDate1);
c.setDateDebut(date1);
}
catch (ParseException ex) {
System.out.println(ex.getMessage());
}