com.fasterxml.jackson.databind.ser.std.DateSerializer.java Source code

Java tutorial

Introduction

Here is the source code for com.fasterxml.jackson.databind.ser.std.DateSerializer.java

Source

package com.fasterxml.jackson.databind.ser.std;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JacksonStdImpl;
import java.text.DateFormat;
import java.util.Date;

@JacksonStdImpl
public class DateSerializer extends DateTimeSerializerBase<Date> {
    public static DateSerializer instance = new DateSerializer();

    public DateSerializer() {
        this(false, null);
    }

    public DateSerializer(boolean paramBoolean, DateFormat paramDateFormat) {
        super(Date.class, paramBoolean, paramDateFormat);
    }

    protected long _timestamp(Date paramDate) {
        if (paramDate == null)
            return 0L;
        return paramDate.getTime();
    }

    public void serialize(Date paramDate, JsonGenerator paramJsonGenerator,
            SerializerProvider paramSerializerProvider) {
        if (this._useTimestamp) {
            paramJsonGenerator.writeNumber(_timestamp(paramDate));
            return;
        }
        if (this._customFormat != null)
            synchronized (this._customFormat) {
                paramJsonGenerator.writeString(this._customFormat.format(paramDate));
                return;
            }
        paramSerializerProvider.defaultSerializeDateValue(paramDate, paramJsonGenerator);
    }

    public DateSerializer withFormat(boolean paramBoolean, DateFormat paramDateFormat) {
        if (paramBoolean)
            return new DateSerializer(true, null);
        return new DateSerializer(false, paramDateFormat);
    }
}

/* Location:           /Users/dantheman/src/fffffffffattttt/basis/classes_dex2jar.jar
 * Qualified Name:     com.fasterxml.jackson.databind.ser.std.DateSerializer
 * JD-Core Version:    0.6.2
 */