Class: Java::Util::Date

Inherits:
SimpleDelegator
  • Object
show all
Extended by:
JavaObject
Defined in:
lib/javaobs.rb

Instance Method Summary collapse

Methods included from JavaObject

javaClass

Constructor Details

#initializeDate

Returns a new instance of Date.



113
114
115
# File 'lib/javaobs.rb', line 113

def initialize
  super(Time)
end

Instance Method Details

#_readJavaData(stream) ⇒ Object



122
123
124
125
126
# File 'lib/javaobs.rb', line 122

def _readJavaData(stream)
  data = stream.readBlockData
  t, = data.unpack("Q")
  __setobj__(Time.at(t / 1000, (t % 1000) * 1000))
end

#_writeJavaData(stream) ⇒ Object

Get the data in the form needed for the Java date serialization.



129
130
131
132
# File 'lib/javaobs.rb', line 129

def _writeJavaData(stream)
  t = __getobj__.tv_sec * 1000 + __getobj__.tv_usec / 1000
  stream.writeBlockData([t].pack("Q"))
end

#time=(time) ⇒ Object

Set the time with a Time object.



118
119
120
# File 'lib/javaobs.rb', line 118

def time=(time)
  __setobj__(time)
end