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


Java DateTime.PlusAdjuster方法代码示例

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


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

示例1: test_badPlusAdjusterChrono

import java.time.calendrical.DateTime; //导入方法依赖的package包/类
@Test(groups = { "tck" }, dataProvider = "calendars")
public void test_badPlusAdjusterChrono(Chrono chrono) {

  LocalDate refDate = LocalDate.of(1900, 1, 1);
  ChronoZonedDateTime czdt = chrono.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC);
  for (Chrono[] clist : data_of_calendars()) {
    Chrono chrono2 = clist[0];
    ChronoZonedDateTime<?> czdt2 = chrono2.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC);
    DateTime.PlusAdjuster adjuster = new FixedAdjuster(czdt2);
    if (chrono != chrono2) {
      try {
        ChronoZonedDateTime<?> notreached = czdt.plus(adjuster);
        Assert.fail("WithAdjuster should have thrown a ClassCastException, " + "required: " + czdt + ", supplied: "
            + czdt2);
      } catch (ClassCastException cce) {
        // Expected exception; not an error
      }
    } else {
      // Same chronology,
      ChronoZonedDateTime<?> result = czdt.plus(adjuster);
      assertEquals(result, czdt2, "WithAdjuster failed to replace date time");
    }
  }
}
 
开发者ID:m-m-m,项目名称:java8-backports,代码行数:25,代码来源:TestChronoZonedDateTime.java

示例2: test_badPlusAdjusterChrono

import java.time.calendrical.DateTime; //导入方法依赖的package包/类
@Test(groups = { "tck" }, dataProvider = "calendars")
public void test_badPlusAdjusterChrono(Chrono chrono) {

  LocalDate refDate = LocalDate.of(1900, 1, 1);
  ChronoLocalDate date = chrono.date(refDate);
  for (Chrono[] clist : data_of_calendars()) {
    Chrono chrono2 = clist[0];
    ChronoLocalDate<?> date2 = chrono2.date(refDate);
    DateTime.PlusAdjuster adjuster = new FixedAdjuster(date2);
    if (chrono != chrono2) {
      try {
        ChronoLocalDate<?> notreached = date.plus(adjuster);
        Assert.fail("WithAdjuster should have thrown a ClassCastException");
      } catch (ClassCastException cce) {
        // Expected exception; not an error
      }
    } else {
      // Same chronology,
      ChronoLocalDate<?> result = date.plus(adjuster);
      assertEquals(result, date2, "WithAdjuster failed to replace date");
    }
  }
}
 
开发者ID:m-m-m,项目名称:java8-backports,代码行数:24,代码来源:TestChronoLocalDate.java

示例3: test_badPlusAdjusterChrono

import java.time.calendrical.DateTime; //导入方法依赖的package包/类
@Test(groups = { "tck" }, dataProvider = "calendars")
public void test_badPlusAdjusterChrono(Chrono chrono) {

  LocalDate refDate = LocalDate.of(1900, 1, 1);
  ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON);
  for (Chrono[] clist : data_of_calendars()) {
    Chrono chrono2 = clist[0];
    ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON);
    DateTime.PlusAdjuster adjuster = new FixedAdjuster(cdt2);
    if (chrono != chrono2) {
      try {
        ChronoLocalDateTime<?> notreached = cdt.plus(adjuster);
        Assert.fail("WithAdjuster should have thrown a ClassCastException, " + "required: " + cdt + ", supplied: "
            + cdt2);
      } catch (ClassCastException cce) {
        // Expected exception; not an error
      }
    } else {
      // Same chronology,
      ChronoLocalDateTime<?> result = cdt.plus(adjuster);
      assertEquals(result, cdt2, "WithAdjuster failed to replace date time");
    }
  }
}
 
开发者ID:m-m-m,项目名称:java8-backports,代码行数:25,代码来源:TestChronoLocalDateTime.java


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