Using JRuby, is there a good way to convert a Java Date object into a JRuby Time object? I'm using the latest version of JRuby (1.3.1) and Java SE 6.
getInstance() method the date from calendar object is obtained and using getTime() method it is converted to Date object. Date object to Calendar object, Date d=new Date(1515660075000l);
Use the toJSON() method to get a string representation of the Date object. Pass the JSON string to the Date() constructor. The Date() constructor will parse the ISO string and will create a Date object.
You can make use of the following DateFormat. SimpleDateFormat myDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); myDate. setTimeZone(TimeZone. getTimeZone("UTC")); Date newDate = myDate.
This should work fine:
Time.at(java.util.Date.new.getTime/1000)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With