Skip to content

Commit

Permalink
Work around bug where org.joda.time.DateTime.new(DateTimeZone) invoke…
Browse files Browse the repository at this point in the history
…s the Object constructor instead of the DateTimeZone argument constructor.
  • Loading branch information
jordansissel committed Oct 11, 2012
1 parent 1898cc4 commit 9c264c6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/logstash/time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ module LogStash::Time
DateTimeZone = org.joda.time.DateTimeZone
def self.now
# org.joda.time.DateTime#to_s returns the time in ISO8601 form :)
return DateTime.new(DateTimeZone::UTC).to_s
# Could call DateTime.new(DateTimeZone::UTC) but JRuby calls the
# DateTime#new(Object) constructor instead of the
# DateTime#new(DateTimeZone) constructor. I was unable to get java_send to invoke this constructor,
# so instead I have to do DateTime#new#withZone(UTC)
return DateTime.new.withZone(DateTimeZone::UTC).to_s
end # def initialize
else
# Otherwise, use ruby stdlib Time, which is much slower than Joda.
Expand Down

0 comments on commit 9c264c6

Please sign in to comment.