org.apache.brooklyn.util.time.Time.getTimeZone()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(2.3k)|赞(0)|评价(0)|浏览(171)

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

Time.getTimeZone介绍

[英]convert a TimeZone e.g. Europe/London to an offset string as at the given day, e.g. +0100 or +0000 depending daylight savings, absent with nice error if zone unknown
[中]将一个时区(例如欧洲/伦敦)转换为给定日期的偏移字符串,例如+0100或+0000(取决于夏令时),如果区域未知,则不存在很好的错误

代码示例

代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common

/** convert a TimeZone e.g. Europe/London to an offset string as at the given day, e.g. +0100 or +0000 depending daylight savings,
 * absent with nice error if zone unknown */
public static Maybe<String> getTimeZoneOffsetString(String tz, int year, int month, int day) {
  TimeZone tzz = getTimeZone(tz);
  if (tzz==null) return Maybe.absent("Unknown time zone code: "+tz);
  return Maybe.of(getTimeZoneOffsetString(tzz, year, month, day));
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common

if ("EST".equals(code)) return getTimeZone("America/New_York");
if ("EDT".equals(code)) return getTimeZone("America/New_York");
if ("PST".equals(code)) return getTimeZone("America/Los_Angeles");
if ("PDT".equals(code)) return getTimeZone("America/Los_Angeles");
if ("CST".equals(code)) return getTimeZone("America/Chicago");
if ("CDT".equals(code)) return getTimeZone("America/Chicago");
if ("MST".equals(code)) return getTimeZone("America/Denver");
if ("MDT".equals(code)) return getTimeZone("America/Denver");
if ("BST".equals(code)) return getTimeZone("Europe/London");  // otherwise BST is Bangladesh!
if ("CEST".equals(code)) return getTimeZone("Europe/Paris");

代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common

tzz = getTimeZone(tz);

代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common

@Test
public void testMakeDateString() {
  String in1 = "2015-06-15T12:34:56";
  Date d1 = Time.parseDate(in1);
  Assert.assertEquals(Time.makeDateString(d1), in1.replace('T', ' ')+".000");
  
  String in2 = "2015-06-15T12:34:56Z";
  Date d2 = Time.parseDate(in2);
  Assert.assertEquals(Time.makeDateString(d2, Time.DATE_FORMAT_ISO8601, Time.getTimeZone("UTC")), in1+".000+0000");
}

相关文章