class Neo4j::TypeConverters::DateTimeConverter

Converts DateTime objects to and from Java long types. Must be timezone UTC.

Public Class Methods

convert?(clazz_or_symbol) click to toggle source
# File lib/neo4j/type_converters/type_converters.rb, line 170
def convert?(clazz_or_symbol)
  DateTime == clazz_or_symbol || :datetime == clazz_or_symbol
end
to_java(value) click to toggle source

Converts the given DateTime (UTC) value to an Fixnum. Only utc times are supported !

# File lib/neo4j/type_converters/type_converters.rb, line 176
def to_java(value)
  return nil if value.nil?
  if value.class == Date
    Time.utc(value.year, value.month, value.day, 0, 0, 0).to_i
  else
    Time.utc(value.year, value.month, value.day, value.hour, value.min, value.sec).to_i
  end
end
to_ruby(value) click to toggle source
# File lib/neo4j/type_converters/type_converters.rb, line 185
def to_ruby(value)
  return nil if value.nil?
  t = Time.at(value).utc
  DateTime.civil(t.year, t.month, t.day, t.hour, t.min, t.sec)
end