当前位置: 首页>>代码示例>>Java>>正文


Java ZoneId.of方法代码示例

本文整理汇总了Java中org.threeten.bp.ZoneId.of方法的典型用法代码示例。如果您正苦于以下问题:Java ZoneId.of方法的具体用法?Java ZoneId.of怎么用?Java ZoneId.of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.threeten.bp.ZoneId的用法示例。


在下文中一共展示了ZoneId.of方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: plat4725

import org.threeten.bp.ZoneId; //导入方法依赖的package包/类
@Test(enabled = false)
/** 
 * Time between dates in different time zones, when one is near midnight.
 * Trouble arises because timeBetween(date1,date2) != -1 * timeBetween(date2,date1).
 * TimeCalculator computes time in ACTACT Daycount convention, hence fractions of a day are rounded to either 0 or 1 day's year fraction..
 */
public void plat4725() {
  ZoneId gmt = ZoneId.of("GMT");
  ZoneId london = ZoneId.of("+01:00");

  final ZonedDateTime date1 = ZonedDateTime.of(2013, 9, 24, 0, 0, 1, 0, london);
  final ZonedDateTime date2 = ZonedDateTime.of(2013, 9, 24, 9, 2, 45,936, gmt);
  final double time12 = TimeCalculator.getTimeBetween(date1, date2);
  final double time21 = TimeCalculator.getTimeBetween(date2, date1);
  assertEquals("TimeCalculator: across midnight", -1 * time12, time21, TOLERANCE);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:17,代码来源:TimeCalculatorTest.java

示例2: buildDateContext

import org.threeten.bp.ZoneId; //导入方法依赖的package包/类
@Test
public void buildDateContext() throws Exception {
    Instant now = ZonedDateTime.of(2015, 8, 24, 9, 44, 5, 0, ZoneId.of("Africa/Kigali")).toInstant();
    EvaluationContext container = new EvaluationContext(new HashMap<String, Object>(), ZoneId.of("Africa/Kigali"), DateStyle.DAY_FIRST, now);

    Map<String, String> context = RunState.buildDateContext(container);

    assertThat(context, hasEntry("*", "2015-08-24T09:44:05+02:00"));
    assertThat(context, hasEntry("now", "2015-08-24T09:44:05+02:00"));
    assertThat(context, hasEntry("today", "24-08-2015"));
    assertThat(context, hasEntry("tomorrow", "25-08-2015"));
    assertThat(context, hasEntry("yesterday", "23-08-2015"));

    container = new EvaluationContext(new HashMap<String, Object>(), ZoneId.of("Africa/Kigali"), DateStyle.MONTH_FIRST, now);

    context = RunState.buildDateContext(container);

    assertThat(context, hasEntry("*", "2015-08-24T09:44:05+02:00"));
    assertThat(context, hasEntry("now", "2015-08-24T09:44:05+02:00"));
    assertThat(context, hasEntry("today", "08-24-2015"));
    assertThat(context, hasEntry("tomorrow", "08-25-2015"));
    assertThat(context, hasEntry("yesterday", "08-23-2015"));
}
 
开发者ID:rapidpro,项目名称:flows,代码行数:24,代码来源:RunStateTest.java

示例3: provideClock

import org.threeten.bp.ZoneId; //导入方法依赖的package包/类
@Provides
@Singleton
public Clock provideClock() {
  Instant instant = Instant.parse("2016-05-06T10:15:30.00Z");
  ZoneId zoneId = ZoneId.of(DEFAULT_TIME_ZONE_STRING);
  return Clock.fixed(instant, zoneId);
}
 
开发者ID:xmartlabs,项目名称:bigbang,代码行数:8,代码来源:MockClockModule.java

示例4: setUp

import org.threeten.bp.ZoneId; //导入方法依赖的package包/类
@BeforeMethod
public void setUp() {
  master = new InMemoryExchangeMaster();
  ManageableExchange inputExchange = new ManageableExchange(BUNDLE_FULL, NAME, GB, ZoneId.of("Europe/London"));
  ExchangeDocument inputDoc = new ExchangeDocument(inputExchange);
  addedDoc = master.add(inputDoc);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:8,代码来源:InMemoryExchangeMasterTest.java

示例5: testAddExchange

import org.threeten.bp.ZoneId; //导入方法依赖的package包/类
@Test
public void testAddExchange() {
  final ManageableExchange target = new ManageableExchange(ExternalIdBundle.of("A", "B"), "Test", ExternalIdBundle.EMPTY, ZoneId.of("Europe/London"));
  final ExchangeDocument request = new ExchangeDocument(target);
  
  final ExchangeDocument result = new ExchangeDocument(target);
  result.setUniqueId(UID);
  when(_underlying.add(same(request))).thenReturn(result);
  
  Response test = _resource.add(_uriInfo, request);
  assertEquals(Status.CREATED.getStatusCode(), test.getStatus());
  assertSame(result, test.getEntity());
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:14,代码来源:DataExchangeMasterResourceTest.java

示例6: testGetExchange

import org.threeten.bp.ZoneId; //导入方法依赖的package包/类
@Test
public void testGetExchange() {
  final ManageableExchange target = new ManageableExchange(ExternalIdBundle.of("A", "B"), "Test", ExternalIdBundle.EMPTY, ZoneId.of("Europe/London"));
  final ExchangeDocument result = new ExchangeDocument(target);
  when(_underlying.get(OID, VersionCorrection.LATEST)).thenReturn(result);
  
  Response test = _resource.get(null, null);
  assertEquals(Status.OK.getStatusCode(), test.getStatus());
  assertSame(result, test.getEntity());
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:11,代码来源:DataExchangeResourceTest.java

示例7: testUpdateExchange

import org.threeten.bp.ZoneId; //导入方法依赖的package包/类
@Test
public void testUpdateExchange() {
  final ManageableExchange target = new ManageableExchange(ExternalIdBundle.of("A", "B"), "Test", ExternalIdBundle.EMPTY, ZoneId.of("Europe/London"));
  final ExchangeDocument request = new ExchangeDocument(target);
  request.setUniqueId(OID.atLatestVersion());
  
  final ExchangeDocument result = new ExchangeDocument(target);
  result.setUniqueId(OID.atVersion("1"));
  when(_underlying.update(same(request))).thenReturn(result);
  
  Response test = _resource.update(_uriInfo, request);
  assertEquals(Status.CREATED.getStatusCode(), test.getStatus());
  assertSame(result, test.getEntity());
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:15,代码来源:DataExchangeResourceTest.java

示例8: fromJson

import org.threeten.bp.ZoneId; //导入方法依赖的package包/类
public static Org fromJson(JsonElement elm) {
    JsonObject obj = elm.getAsJsonObject();
    return new Org(
            obj.get("country").getAsString(),
            obj.get("primary_language").getAsString(),
            ZoneId.of(obj.get("timezone").getAsString()),
            DateStyle.valueOf(obj.get("date_style").getAsString().toUpperCase()),
            obj.get("anon").getAsBoolean()
    );
}
 
开发者ID:rapidpro,项目名称:flows,代码行数:11,代码来源:Org.java

示例9: initBaseData

import org.threeten.bp.ZoneId; //导入方法依赖的package包/类
@Before
public void initBaseData() throws Exception {
    m_org = new Org("RW", "eng", ZoneId.of("Africa/Kigali"), DateStyle.DAY_FIRST, false);

    m_fields = new ArrayList<>(Arrays.asList(
            new Field("gender", "Gender", Field.ValueType.TEXT),
            new Field("age", "Age", Field.ValueType.DECIMAL),
            new Field("joined", "Joined", Field.ValueType.DATETIME)
    ));

    Map<String, String> contactFieldValues = new HashMap<>();
    contactFieldValues.put("gender", "M");
    contactFieldValues.put("age", "34");
    contactFieldValues.put("joined", "2015-10-06T11:30:01.123Z");

    m_contact = new Contact(
            "1234-1234",
            "Joe Flow",
            new ArrayList<>(Arrays.asList(
                    ContactUrn.fromString("tel:+260964153686"),
                    ContactUrn.fromString("twitter:realJoeFlow")
            )),
            new LinkedHashSet<>(Arrays.asList("Testers", "Developers")),
            contactFieldValues,
            "eng"
    );
}
 
开发者ID:rapidpro,项目名称:flows,代码行数:28,代码来源:BaseFlowsTest.java

示例10: buildContext

import org.threeten.bp.ZoneId; //导入方法依赖的package包/类
@Test
public void buildContext() {
    Input input = Input.of("Hello");
    input.m_time = ZonedDateTime.of(2015, 9, 30, 14, 31, 30, 0, ZoneOffset.UTC).toInstant();

    EvaluationContext container = new EvaluationContext(new HashMap<String, Object>(), ZoneId.of("Africa/Kigali"), DateStyle.DAY_FIRST);

    Map<String, String> contactContext = m_contact.buildContext(m_run, container);

    Map<String, Object> context =  input.buildContext(container, contactContext);
    assertThat(context, hasEntry("*", (Object) "Hello"));
    assertThat(context, hasEntry("value", (Object) "Hello"));
    assertThat(context, hasEntry("time", (Object) "2015-09-30T16:31:30+02:00"));
    assertThat(context, hasEntry("contact", (Object) contactContext));

    input = Input.of(new BigDecimal("123.456"));

    context =  input.buildContext(container, contactContext);
    assertThat(context, hasEntry("*", (Object) "123.456"));
    assertThat(context, hasEntry("value", (Object) "123.456"));

    input = Input.of(LocalDate.of(2015, 9, 21));

    context =  input.buildContext(container, contactContext);
    assertThat(context, hasEntry("*", (Object) "21-09-2015"));
    assertThat(context, hasEntry("value", (Object) "21-09-2015"));

    input = Input.of(ZonedDateTime.of(2015, 9, 21, 13, 30, 0, 0, ZoneId.of("UTC")));

    context =  input.buildContext(container, contactContext);
    assertThat(context, hasEntry("*", (Object) "2015-09-21T15:30:00+02:00"));
    assertThat(context, hasEntry("value", (Object) "2015-09-21T15:30:00+02:00"));
}
 
开发者ID:rapidpro,项目名称:flows,代码行数:34,代码来源:InputTest.java

示例11: mockedClock

import org.threeten.bp.ZoneId; //导入方法依赖的package包/类
private static Clock mockedClock() {
  Instant instant = Instant.parse("2016-10-16T10:15:30.00Z");
  ZoneId zoneId = ZoneId.of("GMT-03:00");
  return Clock.fixed(instant, zoneId);
}
 
开发者ID:xmartlabs,项目名称:XLMaterialCalendarView,代码行数:6,代码来源:MainActivity.java

示例12: mockExecutionContext

import org.threeten.bp.ZoneId; //导入方法依赖的package包/类
private FunctionExecutionContext mockExecutionContext() {
  final FunctionExecutionContext context = new FunctionExecutionContext();
  final ZoneId zone = ZoneId.of("UTC");
  context.setValuationClock(Clock.fixed(nowDate.atStartOfDay(zone).toInstant(), zone));
  return context;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:7,代码来源:DateConstraintTest.java

示例13: createOrg

import org.threeten.bp.ZoneId; //导入方法依赖的package包/类
public static Org createOrg(DBOrg org) {
    return new Org(org.getCountry(), org.getPrimaryLanguage(),
                   ZoneId.of(org.getTimezone()), getDateStyle(org),
                   org.isAnonymous());
}
 
开发者ID:rapidpro,项目名称:surveyor,代码行数:6,代码来源:RunnerUtil.java

示例14: getTimeZone

import org.threeten.bp.ZoneId; //导入方法依赖的package包/类
/**
 * Gets the time-zone.
 * For larger regions, there can be multiple time-zones, so this is only reliable
 * for municipalities.
 * @return the value of the property
 */
public ZoneId getTimeZone() {
  String id = _externalIdBundle.getValue(ExternalSchemes.TZDB_TIME_ZONE);
  return (id != null ? ZoneId.of(id) : null);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:11,代码来源:ManageableRegion.java

示例15: toZonedDateTime

import org.threeten.bp.ZoneId; //导入方法依赖的package包/类
/**
 * Converts GregorianCalendar to ZonedDateTime
 * 
 * @param calendar the calendar, not null
 * @return the zoned-date-time, not null
 */
public static ZonedDateTime toZonedDateTime(GregorianCalendar calendar) {
  ZoneId zone = ZoneId.of(calendar.getTimeZone().getID());
  Instant instant = Instant.ofEpochMilli(calendar.getTimeInMillis());
  return ZonedDateTime.ofInstant(instant, zone);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:12,代码来源:DateUtils.java


注:本文中的org.threeten.bp.ZoneId.of方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。