當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。