Skip to content
This repository
tag: 1.5.0.RC3
Fetching contributors…

Cannot retrieve contributors at this time

file 15 lines (12 sloc) 0.528 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
require 'test/unit'
require 'java'

class TestPrimitiveToJava < Test::Unit::TestCase
  def test_primitive_conversion
    t = Time.now

    dc = org.jruby.javasupport.test.DateHolder.new
    tz_pattern = t.zone == 'UTC' ? "'UTC'" : "Z"
    sdf = java.text.SimpleDateFormat.new("EEE MMM dd HH:mm:ss #{tz_pattern} yyyy", java.util.Locale::ENGLISH)
    dc.date = t

    assert(t.to_s.eql?(sdf.format(dc.date)), "Ruby time #{t} not converted to java date correctly: #{sdf.format(dc.date)}")
  end
end
Something went wrong with that request. Please try again.