Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.fasterxml.jackson.databind.ser.std;
 
 
 
Standard serializer for java.util.Calendar. As with other time/date types, is configurable to produce timestamps (standard Java 64-bit timestamp) or textual formats (usually ISO-8601).
public class CalendarSerializer
    public static final CalendarSerializer instance = new CalendarSerializer();
    public CalendarSerializer() { this(falsenull); }
    public CalendarSerializer(boolean useTimestampDateFormat customFormat) {
        super(Calendar.classuseTimestampcustomFormat);
    }
    @Override
    public CalendarSerializer withFormat(boolean timestampDateFormat customFormat)
    {
        if (timestamp) {
            return new CalendarSerializer(truenull);
        }
        return new CalendarSerializer(falsecustomFormat);
    }
    @Override
    protected long _timestamp(Calendar value) {
        return (value == null) ? 0L : value.getTimeInMillis();
    }
    @Override
    public void serialize(Calendar valueJsonGenerator jgenSerializerProvider provider)
        throws IOExceptionJsonGenerationException
    {
        if () {
            jgen.writeNumber(_timestamp(value));
        } else if ( != null) {
            // 21-Feb-2011, tatu: not optimal, but better than alternatives:
            synchronized () {
                jgen.writeString(.format(value));
            }
        } else {
            provider.defaultSerializeDateValue(value.getTime(), jgen);
        }
    }
New to GrepCode? Check out our FAQ X