mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-20 04:39:04 +00:00
Merge pull request #566 from TheHollidayInn/serialize-dates-to-timestamp
Updated serializers to convert dates to timestamps
This commit is contained in:
commit
6fa9272ce7
2 changed files with 23 additions and 2 deletions
|
|
@ -0,0 +1,21 @@
|
|||
package com.magicmicky.habitrpgwrapper.lib.utils;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
|
||||
import org.json.JSONStringer;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by keithholliday on 6/19/16.
|
||||
*/
|
||||
public class DateSerializer implements JsonSerializer<Date> {
|
||||
@Override
|
||||
public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
return new JsonPrimitive(src.getTime());
|
||||
}
|
||||
}
|
||||
|
|
@ -18,8 +18,8 @@ public class RemindersItemSerializer
|
|||
public JsonElement serialize(RemindersItem src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
JsonObject object = new JsonObject();
|
||||
object.addProperty("id", src.getId());
|
||||
object.addProperty("startDate", src.getStartDate().toString());
|
||||
object.addProperty("time", src.getTime().toString());
|
||||
object.addProperty("startDate", src.getStartDate().getTime());
|
||||
object.addProperty("time", src.getTime().getTime());
|
||||
return object;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue