public static IRubyObject prepareRubyTimeFromSqlDate(Ruby runtime, Date date) { if (date.getTime() + 3600000 == 0) { return runtime.getNil(); } RubyTime rbTime = RubyTime.newTime(runtime, date.getTime()); rbTime.extend(new IRubyObject[]{runtime.getModule("TimeFormatter")}); return rbTime; // SimpleDateFormat sdf = new SimpleDateFormat("HH-mm-ss"); // TODO proper format? // return runtime.newString(sdf.format(rbTime.getJavaDate())); }
public static IRubyObject parse_date_time(Ruby runtime, Timestamp ts) { RubyTime time = RubyTime.newTime(runtime, ts.getTime()); time.extend(new IRubyObject[] {runtime.getModule("DatetimeFormatter")}); return time; }
public static IRubyObject parse_time(Ruby runtime, Time tm) { RubyTime time = RubyTime.newTime(runtime, tm.getTime()); time.extend(new IRubyObject[] {runtime.getModule("TimeFormatter")}); return (time.getUSec() != 0) ? time : runtime.getNil(); }
public static IRubyObject parse_date(Ruby runtime, Date dt) { RubyTime time = RubyTime.newTime(runtime, dt.getTime()); time.extend(new IRubyObject[] {runtime.getModule("DateFormatter")}); return time; }