I am using GSON library to serialize and deserialize java objects on both client and server sides. I have a scenario in which I have a date in milliseconds on the client, but on the server, I have same field with data type of Date
. Here is the example code at the client end -
class Dog {
long id;
long purchaseDate; //This is in milliseconds
String name;
boolean status;
}
And on server side -
class Dog {
long id;
Date purchaseDate; //Convert milliseconds to date
String name;
int status; //If boolean is false then 0 else 1
}
How to do it using GSON library. If it is not possible through GSON, then which library will be suitable for this kind of serialization/ deserialization?