本文整理了Java中org.jruby.Ruby.getTime
方法的一些代码示例,展示了Ruby.getTime
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.getTime
方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:getTime
暂无
代码示例来源:origin: org.jruby/jruby-complete
public static RubyTime newTime(Ruby runtime, DateTime dt) {
return new RubyTime(runtime, runtime.getTime(), dt);
}
代码示例来源:origin: org.jruby/jruby-complete
static void load(Ruby runtime) {
runtime.getTime().defineAnnotatedMethods(TimeExt.class);
}
代码示例来源:origin: org.jruby/jruby-core
static void load(Ruby runtime) {
runtime.getTime().defineAnnotatedMethods(TimeExt.class);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public static RubyTime newTime(Ruby runtime, DateTime dt) {
return new RubyTime(runtime, runtime.getTime(), dt);
}
代码示例来源:origin: org.jruby/jruby-core
public static RubyTime newTime(Ruby runtime, DateTime dt) {
return new RubyTime(runtime, runtime.getTime(), dt);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public static RubyTime newTime(Ruby runtime, DateTime dt) {
return new RubyTime(runtime, runtime.getTime(), dt);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public static RubyTime newTime(Ruby runtime, DateTime dt, long nsec) {
RubyTime t = new RubyTime(runtime, runtime.getTime(), dt);
t.setNSec(nsec);
return t;
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod // Time.local(year, mon, mday)
public RubyTime to_time(ThreadContext context) {
final Ruby runtime = context.runtime;
DateTime dt = this.dt;
dt = new DateTime(adjustJodaYear(dt.getYear()), dt.getMonthOfYear(), dt.getDayOfMonth(),
0, 0, 0,
RubyTime.getLocalTimeZone(runtime)
);
return new RubyTime(runtime, runtime.getTime(), dt);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public static RubyTime newTime(Ruby runtime, DateTime dt, long nsec) {
RubyTime t = new RubyTime(runtime, runtime.getTime(), dt);
t.setNSec(nsec);
return t;
}
代码示例来源:origin: org.jruby/jruby-core
@JRubyMethod // Time.local(year, mon, mday)
public RubyTime to_time(ThreadContext context) {
final Ruby runtime = context.runtime;
DateTime dt = this.dt;
dt = new DateTime(adjustJodaYear(dt.getYear()), dt.getMonthOfYear(), dt.getDayOfMonth(),
0, 0, 0,
RubyTime.getLocalTimeZone(runtime)
);
return new RubyTime(runtime, runtime.getTime(), dt);
}
代码示例来源:origin: org.jruby/jruby-complete
/**
* Create new (Ruby) Time instance.
*
* Note that {@code dt} of {@code org.joda.time.DateTime} represents the integer part and
* the fraction part to milliseconds, and {@code nsec} the nano part (4 to 9 decimal places).
*
* For example, {@code RubyTime.newTime(rt, new DateTime(987000), 345678)} creates an epoch
* second of {@code 987.000345678}, not {@code 987000.345678}.
*
* @param runtime the runtime
* @param dt the integer part of time + the fraction part in milliseconds
* @param nsec the nanos only party of the time (millis excluded)
* @see #setNSec(long)
* @return the new Time
*/
public static RubyTime newTime(Ruby runtime, DateTime dt, long nsec) {
RubyTime t = new RubyTime(runtime, runtime.getTime(), dt);
t.setNSec(nsec);
return t;
}
代码示例来源:origin: org.jruby/jruby-core
/**
* Create new (Ruby) Time instance.
*
* Note that {@code dt} of {@code org.joda.time.DateTime} represents the integer part and
* the fraction part to milliseconds, and {@code nsec} the nano part (4 to 9 decimal places).
*
* For example, {@code RubyTime.newTime(rt, new DateTime(987000), 345678)} creates an epoch
* second of {@code 987.000345678}, not {@code 987000.345678}.
*
* @param runtime the runtime
* @param dt the integer part of time + the fraction part in milliseconds
* @param nsec the nanos only party of the time (millis excluded)
* @see #setNSec(long)
* @return the new Time
*/
public static RubyTime newTime(Ruby runtime, DateTime dt, long nsec) {
RubyTime t = new RubyTime(runtime, runtime.getTime(), dt);
t.setNSec(nsec);
return t;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
/**
* Extract a timeval (an array of 2 longs: seconds and microseconds from epoch) from
* an IRubyObject.
*/
private static long[] extractTimeval(Ruby runtime, IRubyObject value) {
long[] timeval = new long[2];
if (value instanceof RubyFloat) {
timeval[0] = Platform.IS_32_BIT ? RubyNumeric.num2int(value) : RubyNumeric.num2long(value);
double fraction = ((RubyFloat) value).getDoubleValue() % 1.0;
timeval[1] = (long)(fraction * 1e6 + 0.5);
} else if (value instanceof RubyNumeric) {
timeval[0] = Platform.IS_32_BIT ? RubyNumeric.num2int(value) : RubyNumeric.num2long(value);
timeval[1] = 0;
} else {
RubyTime time;
if (value instanceof RubyTime) {
time = ((RubyTime) value);
} else {
time = (RubyTime) TypeConverter.convertToType(value, runtime.getTime(), "to_time", true);
}
timeval[0] = Platform.IS_32_BIT ? RubyNumeric.num2int(time.to_i()) : RubyNumeric.num2long(time.to_i());
timeval[1] = Platform.IS_32_BIT ? RubyNumeric.num2int(time.usec()) : RubyNumeric.num2long(time.usec());
}
return timeval;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
/**
* Extract a timeval (an array of 2 longs: seconds and microseconds from epoch) from
* an IRubyObject.
*/
private static long[] extractTimeval(Ruby runtime, IRubyObject value) {
long[] timeval = new long[2];
if (value instanceof RubyFloat) {
timeval[0] = Platform.IS_32_BIT ? RubyNumeric.num2int(value) : RubyNumeric.num2long(value);
double fraction = ((RubyFloat) value).getDoubleValue() % 1.0;
timeval[1] = (long)(fraction * 1e6 + 0.5);
} else if (value instanceof RubyNumeric) {
timeval[0] = Platform.IS_32_BIT ? RubyNumeric.num2int(value) : RubyNumeric.num2long(value);
timeval[1] = 0;
} else {
RubyTime time;
if (value instanceof RubyTime) {
time = ((RubyTime) value);
} else {
time = (RubyTime) TypeConverter.convertToType(value, runtime.getTime(), "to_time", true);
}
timeval[0] = Platform.IS_32_BIT ? RubyNumeric.num2int(time.to_i()) : RubyNumeric.num2long(time.to_i());
timeval[1] = Platform.IS_32_BIT ? RubyNumeric.num2int(time.usec()) : RubyNumeric.num2long(time.usec());
}
return timeval;
}
代码示例来源:origin: org.jruby/jruby-complete
/**
* Extract a timespec (an array of 2 longs: seconds and nanoseconds from epoch) from
* an IRubyObject.
*/
private static long[] extractTimespec(ThreadContext context, IRubyObject value) {
long[] timespec = new long[2];
if (value instanceof RubyFloat) {
timespec[0] = Platform.IS_32_BIT ? RubyNumeric.num2int(value) : RubyNumeric.num2long(value);
double fraction = ((RubyFloat) value).getDoubleValue() % 1.0;
timespec[1] = (long)(fraction * 1e9 + 0.5);
} else if (value instanceof RubyNumeric) {
timespec[0] = Platform.IS_32_BIT ? RubyNumeric.num2int(value) : RubyNumeric.num2long(value);
timespec[1] = 0;
} else {
RubyTime time;
if (value instanceof RubyTime) {
time = ((RubyTime) value);
} else {
time = (RubyTime) TypeConverter.convertToType(context, value, context.runtime.getTime(), sites(context).to_time_checked, true);
}
timespec[0] = Platform.IS_32_BIT ? RubyNumeric.num2int(time.to_i()) : RubyNumeric.num2long(time.to_i());
timespec[1] = Platform.IS_32_BIT ? RubyNumeric.num2int(time.nsec()) : RubyNumeric.num2long(time.nsec());
}
return timespec;
}
代码示例来源:origin: org.jruby/jruby-core
/**
* Extract a timespec (an array of 2 longs: seconds and nanoseconds from epoch) from
* an IRubyObject.
*/
private static long[] extractTimespec(ThreadContext context, IRubyObject value) {
long[] timespec = new long[2];
if (value instanceof RubyFloat) {
timespec[0] = Platform.IS_32_BIT ? RubyNumeric.num2int(value) : RubyNumeric.num2long(value);
double fraction = ((RubyFloat) value).getDoubleValue() % 1.0;
timespec[1] = (long)(fraction * 1e9 + 0.5);
} else if (value instanceof RubyNumeric) {
timespec[0] = Platform.IS_32_BIT ? RubyNumeric.num2int(value) : RubyNumeric.num2long(value);
timespec[1] = 0;
} else {
RubyTime time;
if (value instanceof RubyTime) {
time = ((RubyTime) value);
} else {
time = (RubyTime) TypeConverter.convertToType(context, value, context.runtime.getTime(), sites(context).to_time_checked, true);
}
timespec[0] = Platform.IS_32_BIT ? RubyNumeric.num2int(time.to_i()) : RubyNumeric.num2long(time.to_i());
timespec[1] = Platform.IS_32_BIT ? RubyNumeric.num2int(time.nsec()) : RubyNumeric.num2long(time.nsec());
}
return timespec;
}
内容来源于网络,如有侵权,请联系作者删除!