org.jruby.Ruby.getTimezoneCache()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(98)

本文整理了Java中org.jruby.Ruby.getTimezoneCache方法的一些代码示例,展示了Ruby.getTimezoneCache的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.getTimezoneCache方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:getTimezoneCache

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;

相关文章

微信公众号

最新文章

更多

Ruby类方法