package mobos.leoss.si.qsystemmobileapp.SupportClasses;

import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;

import java.lang.reflect.Type;
import java.util.Date;
import java.util.TimeZone;

/**
 * Created by Blaz on 10. 06. 2016.
 */
public class DateSerializer implements JsonSerializer<Date> {
    @Override
    public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context) {
        if (src == null) {
            return null;
        }
        return new JsonPrimitive("/Date(" + src.getTime() + TimeZone.getDefault().getRawOffset() + ")/");
    }
}
