JSON deserializer returns datatype is not a long exception at datetime input
0
The JsonDeserializer is capable of taking in a datetime format. However, if you put a datetime into the JSON message, you get an exception. I've drilled down the JAVA code (despite the fact that I am not a JAVA developer...) and found that the deserializer is expecting a long value to convert into date: return new Date(object.getLong(attr)); This is really counter-intuitive to me because in the non-persistent message structure (domain model) we created an object with an attribute of DateTime. I've changed the JSON deserializer to convert a string with a designed format into date. case DateTime: if (object.isNull(attr)) return null; SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); Date returndate = formatter.parse(object.getString(attr)); return returndate; If anyone has a better solution, please give a response.
asked
Rolf Bolt - EGALiT
1 answers
0
Aside from your own solution, I believe the CommunityCommons provides several Java actions to convert a DateTime to Long and the other way around.
Would that suffice when wanting to use the deserializer "as-is"?