Skip to content

Instantly share code, notes, and snippets.

@vikraman
Created February 11, 2013 19:05
Show Gist options
  • Save vikraman/4756717 to your computer and use it in GitHub Desktop.
Save vikraman/4756717 to your computer and use it in GitHub Desktop.
org.joda.time.DateTime serializer for titan
package com.example
import java.nio.ByteBuffer
import org.joda.time.DateTime
import com.thinkaurelius.titan.core.AttributeSerializer
class DateTimeSerializer extends AttributeSerializer[DateTime] {
private val serialVersionUID = 272513079663L
def read(buffer: ByteBuffer): DateTime =
new DateTime(buffer.getLong() + Long.MinValue)
def writeObjectData(buffer: ByteBuffer, obj: DateTime): Unit =
buffer.putLong(obj.getMillis - Long.MinValue)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment