Back to project page dandy.
The source code is released under:
GNU General Public License
If you think the Android project dandy listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.workhabit.drupal.api.json; // w w w . j av a2s . c o m import com.google.gson.*; import java.lang.reflect.Type; import java.util.Date; /** * Handles (de)serialization of Drupal dates from unixtimestamp in seconds to @link java.util.Date */ @SuppressWarnings({"WeakerAccess"}) public class UnixTimeDateAdapter implements JsonDeserializer<Date>, JsonSerializer<Date> { public Date deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException { return new Date(jsonElement.getAsJsonPrimitive().getAsLong() * 1000); } public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context) { return new JsonPrimitive((int)(src.getTime() / 1000)); } }