Converts DateTime objects to and from Java long types. Must be timezone UTC.
- DATETIME_FORMAT
ruby
- def convert_type
DateTime
end
ruby
- def db_type
Integer
end
ruby
- def to_ruby(value)
- t = case value
- when Integer
Time.at(value).utc
- when String
DateTime.strptime(value, DATETIME_FORMAT)
- else
fail ArgumentError, "Invalid value type for DateType property: #{value.inspect}"
end
DateTime.civil(t.year, t.month, t.day, t.hour, t.min, t.sec)
end