本文整理了Java中org.jruby.Ruby.getTimezoneCache
方法的一些代码示例,展示了Ruby.getTimezoneCache
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.getTimezoneCache
方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:getTimezoneCache
暂无
代码示例来源:origin: org.jruby/jruby-complete
public static DateTimeZone getTimeZoneFromString(Ruby runtime, String zone) {
DateTimeZone cachedZone = runtime.getTimezoneCache().get(zone);
if (cachedZone != null) {
return cachedZone;
} else {
DateTimeZone dtz = parseZoneString(runtime, zone);
runtime.getTimezoneCache().put(zone, dtz);
return dtz;
}
}
代码示例来源:origin: org.jruby/jruby-complete
public static DateTimeZone getTimeZoneFromTZString(Ruby runtime, String zone) {
DateTimeZone cachedZone = runtime.getTimezoneCache().get(zone);
if (cachedZone != null) return cachedZone;
DateTimeZone dtz = parseTZString(runtime, zone);
runtime.getTimezoneCache().put(zone, dtz);
return dtz;
}
代码示例来源:origin: org.jruby/jruby-core
public static DateTimeZone getTimeZoneFromTZString(Ruby runtime, String zone) {
DateTimeZone cachedZone = runtime.getTimezoneCache().get(zone);
if (cachedZone != null) return cachedZone;
DateTimeZone dtz = parseTZString(runtime, zone);
runtime.getTimezoneCache().put(zone, dtz);
return dtz;
}
代码示例来源:origin: org.jruby/jruby-core
public static DateTimeZone getTimeZoneFromString(Ruby runtime, String zone) {
DateTimeZone cachedZone = runtime.getTimezoneCache().get(zone);
if (cachedZone != null) {
return cachedZone;
} else {
DateTimeZone dtz = parseZoneString(runtime, zone);
runtime.getTimezoneCache().put(zone, dtz);
return dtz;
}
}
代码示例来源:origin: org.jruby/jruby-complete
public static DateTimeZone getTimeZoneWithOffset(Ruby runtime, String zoneName, int offset) {
// validate_zone_name
zoneName = zoneName.trim();
String zone = zoneName + offset;
DateTimeZone cachedZone = runtime.getTimezoneCache().get(zone);
if (cachedZone != null) {
return cachedZone;
} else {
DateTimeZone dtz = timeZoneWithOffset(zoneName, offset);
runtime.getTimezoneCache().put(zone, dtz);
return dtz;
}
}
代码示例来源:origin: org.jruby/jruby-core
public static DateTimeZone getTimeZoneWithOffset(Ruby runtime, String zoneName, int offset) {
// validate_zone_name
zoneName = zoneName.trim();
String zone = zoneName + offset;
DateTimeZone cachedZone = runtime.getTimezoneCache().get(zone);
if (cachedZone != null) {
return cachedZone;
} else {
DateTimeZone dtz = timeZoneWithOffset(zoneName, offset);
runtime.getTimezoneCache().put(zone, dtz);
return dtz;
}
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public static DateTimeZone getTimeZone(Ruby runtime, long seconds) {
if (seconds >= 60*60*24 || seconds <= -60*60*24) {
throw runtime.newArgumentError("utc_offset out of range");
}
// append "s" to the offset when looking up the cache
String zone = seconds + "s";
DateTimeZone cachedZone = runtime.getTimezoneCache().get(zone);
if (cachedZone != null) return cachedZone;
DateTimeZone dtz = DateTimeZone.forOffsetMillis((int) (seconds * 1000));
runtime.getTimezoneCache().put(zone, dtz);
return dtz;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public static DateTimeZone getTimeZone(Ruby runtime, long seconds) {
if (seconds >= 60*60*24 || seconds <= -60*60*24) {
throw runtime.newArgumentError("utc_offset out of range");
}
// append "s" to the offset when looking up the cache
String zone = seconds + "s";
DateTimeZone cachedZone = runtime.getTimezoneCache().get(zone);
if (cachedZone != null) return cachedZone;
DateTimeZone dtz = DateTimeZone.forOffsetMillis((int) (seconds * 1000));
runtime.getTimezoneCache().put(zone, dtz);
return dtz;
}
代码示例来源:origin: org.jruby/jruby-complete
public static DateTimeZone getTimeZoneFromUtcOffset(ThreadContext context, IRubyObject utcOffset) {
final Ruby runtime = context.runtime;
String strOffset = utcOffset.toString();
DateTimeZone cachedZone = runtime.getTimezoneCache().get(strOffset);
if (cachedZone != null) return cachedZone;
DateTimeZone dtz;
if (utcOffset instanceof RubyString) {
Matcher offsetMatcher = TIME_OFFSET_PATTERN.matcher(strOffset);
if (!offsetMatcher.matches()) {
throw runtime.newArgumentError("\"+HH:MM\" or \"-HH:MM\" expected for utc_offset");
}
String sign = offsetMatcher.group(1);
String hours = offsetMatcher.group(2);
String minutes = offsetMatcher.group(3);
String seconds = offsetMatcher.group(4);
dtz = getTimeZoneFromHHMM(runtime, "", !sign.equals("-"), hours, minutes, seconds);
} else {
RubyNumeric numericOffset = numExact(context, utcOffset);
int newOffset = (int) Math.round(numericOffset.convertToFloat().getDoubleValue() * 1000);
dtz = getTimeZoneWithOffset(runtime, "", newOffset);
}
runtime.getTimezoneCache().put(strOffset, dtz);
return dtz;
}
代码示例来源:origin: org.jruby/jruby-core
public static DateTimeZone getTimeZoneFromUtcOffset(ThreadContext context, IRubyObject utcOffset) {
final Ruby runtime = context.runtime;
String strOffset = utcOffset.toString();
DateTimeZone cachedZone = runtime.getTimezoneCache().get(strOffset);
if (cachedZone != null) return cachedZone;
DateTimeZone dtz;
if (utcOffset instanceof RubyString) {
Matcher offsetMatcher = TIME_OFFSET_PATTERN.matcher(strOffset);
if (!offsetMatcher.matches()) {
throw runtime.newArgumentError("\"+HH:MM\" or \"-HH:MM\" expected for utc_offset");
}
String sign = offsetMatcher.group(1);
String hours = offsetMatcher.group(2);
String minutes = offsetMatcher.group(3);
String seconds = offsetMatcher.group(4);
dtz = getTimeZoneFromHHMM(runtime, "", !sign.equals("-"), hours, minutes, seconds);
} else {
RubyNumeric numericOffset = numExact(context, utcOffset);
int newOffset = (int) Math.round(numericOffset.convertToFloat().getDoubleValue() * 1000);
dtz = getTimeZoneWithOffset(runtime, "", newOffset);
}
runtime.getTimezoneCache().put(strOffset, dtz);
return dtz;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public static DateTimeZone getTimeZone(Ruby runtime, String zone) {
DateTimeZone cachedZone = runtime.getTimezoneCache().get(zone);
runtime.getTimezoneCache().put(originalZone, dtz);
return dtz;
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public static DateTimeZone getTimeZone(Ruby runtime, String zone) {
DateTimeZone cachedZone = runtime.getTimezoneCache().get(zone);
runtime.getTimezoneCache().put(originalZone, dtz);
return dtz;
内容来源于网络,如有侵权,请联系作者删除!