com.fasterxml.jackson.databind.ser.std
Class DateSerializer

java.lang.Object
  extended by com.fasterxml.jackson.databind.JsonSerializer<T>
      extended by com.fasterxml.jackson.databind.ser.std.StdSerializer<T>
          extended by com.fasterxml.jackson.databind.ser.std.StdScalarSerializer<T>
              extended by com.fasterxml.jackson.databind.ser.std.DateTimeSerializerBase<Date>
                  extended by com.fasterxml.jackson.databind.ser.std.DateSerializer
All Implemented Interfaces:
SchemaAware, ContextualSerializer

public class DateSerializer
extends DateTimeSerializerBase<Date>

For efficiency, we will serialize Dates as longs, instead of potentially more readable Strings.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.JsonSerializer
JsonSerializer.None
 
Field Summary
static DateSerializer instance
          Default instance that is used when no contextual configuration is needed.
 
Fields inherited from class com.fasterxml.jackson.databind.ser.std.DateTimeSerializerBase
_customFormat, _useTimestamp
 
Fields inherited from class com.fasterxml.jackson.databind.ser.std.StdSerializer
_handledType
 
Constructor Summary
DateSerializer()
           
DateSerializer(boolean useTimestamp, DateFormat customFormat)
           
 
Method Summary
protected  long _timestamp(Date value)
           
 void serialize(Date value, com.fasterxml.jackson.core.JsonGenerator jgen, SerializerProvider provider)
          Method that can be called to ask implementation to serialize values of type this serializer handles.
 DateSerializer withFormat(boolean timestamp, DateFormat customFormat)
           
 
Methods inherited from class com.fasterxml.jackson.databind.ser.std.DateTimeSerializerBase
createContextual, getSchema, isEmpty
 
Methods inherited from class com.fasterxml.jackson.databind.ser.std.StdScalarSerializer
serializeWithType
 
Methods inherited from class com.fasterxml.jackson.databind.ser.std.StdSerializer
createObjectNode, createSchemaNode, createSchemaNode, handledType, isDefaultSerializer, wrapAndThrow, wrapAndThrow
 
Methods inherited from class com.fasterxml.jackson.databind.JsonSerializer
isUnwrappingSerializer, unwrappingSerializer, usesObjectId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

public static DateSerializer instance
Default instance that is used when no contextual configuration is needed.

Constructor Detail

DateSerializer

public DateSerializer()

DateSerializer

public DateSerializer(boolean useTimestamp,
                      DateFormat customFormat)
Method Detail

withFormat

public DateSerializer withFormat(boolean timestamp,
                                 DateFormat customFormat)
Specified by:
withFormat in class DateTimeSerializerBase<Date>

_timestamp

protected long _timestamp(Date value)
Specified by:
_timestamp in class DateTimeSerializerBase<Date>

serialize

public void serialize(Date value,
                      com.fasterxml.jackson.core.JsonGenerator jgen,
                      SerializerProvider provider)
               throws IOException,
                      com.fasterxml.jackson.core.JsonGenerationException
Description copied from class: JsonSerializer
Method that can be called to ask implementation to serialize values of type this serializer handles.

Specified by:
serialize in class DateTimeSerializerBase<Date>
Parameters:
value - Value to serialize; can not be null.
jgen - Generator used to output resulting Json content
provider - Provider that can be used to get serializers for serializing Objects value contains, if any.
Throws:
IOException
com.fasterxml.jackson.core.JsonGenerationException


Copyright © 2012 fasterxml.com. All Rights Reserved.