Re: How to convert long/milliseconds to DateTime?

From: Mike Nospam

Java developer making the switch.

Welcome!

I have timestamps stored in Oracle as
a long (gotten from java.sql.Timestamp - milliseconds from
some day in
1970). Is there a way to convert that long back into a Ruby
Date/DateTime/Time . Any of these would do.

ri Time.at

Thanks Gavin. I did a lot of Smalltalk programming in the 90’s, so Ruby
has a familiar, fun feel.

I tried this already:

t = Time.at(1161275493444)
puts t

Resulting in:
Exception: bignum too big to convert into `long’

No joy. Am I missing something (else)?

Thanks,

Mike

Gavin K. wrote:

From: Mike Nospam

Java developer making the switch.

Welcome!

I have timestamps stored in Oracle as
a long (gotten from java.sql.Timestamp - milliseconds from
some day in
1970). Is there a way to convert that long back into a Ruby
Date/DateTime/Time . Any of these would do.

ri Time.at

On Wed, 25 Oct 2006, Mike Nospam wrote:

Thanks Gavin. I did a lot of Smalltalk programming in the 90’s, so Ruby
has a familiar, fun feel.

I tried this already:

t = Time.at(1161275493444)
puts t

irb(main):003:0> Time.at(1161275493444 / 1000.0)
=> Thu Oct 19 11:31:33 CDT 2006

Kirk H.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs