samedi 28 mars 2015

Cast Meteor.js DDP date to Java Date



I am using Android DDP Client library to connect my Android client to Meteor-JS server. When I receive a new object I use the following code to parse a "createdAt" field



private Map<String, Object> fields;
private Date timestamp;
/*...*/
timestamp = (Date) fields.get("createdAt");


I wrongfully assumed that it should be of Date type. And I get the exception with an error message:



com.google.gson.internal.LinkedHashTreeMap cannot be cast to java.util.Date


How to parse the Date sent by Meteor correctly?




Aucun commentaire:

Enregistrer un commentaire