Java Code Examples for java.time.chrono.ChronoLocalDateTime#with()
The following examples show how to use
java.time.chrono.ChronoLocalDateTime#with() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TCKChronoLocalDateTime.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider="calendars") public void test_badWithAdjusterChrono(Chronology chrono) { LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); TemporalAdjuster adjuster = new FixedAdjuster(cdt2); if (chrono != chrono2) { try { cdt.with(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.with(adjuster); assertEquals(result, cdt2, "WithAdjuster failed to replace date"); } } }
Example 2
Source File: TCKChronoLocalDateTime.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider="calendars") public void test_badTemporalFieldChrono(Chronology chrono) { LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); TemporalField adjuster = new FixedTemporalField(cdt2); if (chrono != chrono2) { try { cdt.with(adjuster, 1); Assert.fail("TemporalField doWith() should have thrown a ClassCastException" + cdt.getClass() + ", can not be cast to " + cdt2.getClass()); } catch (ClassCastException cce) { // Expected exception; not an error } } else { // Same chronology, ChronoLocalDateTime<?> result = cdt.with(adjuster, 1); assertEquals(result, cdt2, "TemporalField doWith() failed to replace date"); } } }
Example 3
Source File: TCKChronoLocalDateTime.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider="calendars") public void test_badWithAdjusterChrono(Chronology chrono) { LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); TemporalAdjuster adjuster = new FixedAdjuster(cdt2); if (chrono != chrono2) { try { cdt.with(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.with(adjuster); assertEquals(result, cdt2, "WithAdjuster failed to replace date"); } } }
Example 4
Source File: TCKChronoLocalDateTime.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider="calendars") public void test_badTemporalFieldChrono(Chronology chrono) { LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); TemporalField adjuster = new FixedTemporalField(cdt2); if (chrono != chrono2) { try { cdt.with(adjuster, 1); Assert.fail("TemporalField doWith() should have thrown a ClassCastException" + cdt.getClass() + ", can not be cast to " + cdt2.getClass()); } catch (ClassCastException cce) { // Expected exception; not an error } } else { // Same chronology, ChronoLocalDateTime<?> result = cdt.with(adjuster, 1); assertEquals(result, cdt2, "TemporalField doWith() failed to replace date"); } } }
Example 5
Source File: TCKChronoLocalDateTime.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider="calendars") public void test_badWithAdjusterChrono(Chronology chrono) { LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); TemporalAdjuster adjuster = new FixedAdjuster(cdt2); if (chrono != chrono2) { try { cdt.with(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.with(adjuster); assertEquals(result, cdt2, "WithAdjuster failed to replace date"); } } }
Example 6
Source File: TCKChronoLocalDateTime.java From hottub with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider="calendars") public void test_badTemporalFieldChrono(Chronology chrono) { LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); TemporalField adjuster = new FixedTemporalField(cdt2); if (chrono != chrono2) { try { cdt.with(adjuster, 1); Assert.fail("TemporalField doWith() should have thrown a ClassCastException" + cdt.getClass() + ", can not be cast to " + cdt2.getClass()); } catch (ClassCastException cce) { // Expected exception; not an error } } else { // Same chronology, ChronoLocalDateTime<?> result = cdt.with(adjuster, 1); assertEquals(result, cdt2, "TemporalField doWith() failed to replace date"); } } }
Example 7
Source File: TCKChronoLocalDateTime.java From hottub with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider="calendars") public void test_badWithAdjusterChrono(Chronology chrono) { LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); TemporalAdjuster adjuster = new FixedAdjuster(cdt2); if (chrono != chrono2) { try { cdt.with(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.with(adjuster); assertEquals(result, cdt2, "WithAdjuster failed to replace date"); } } }
Example 8
Source File: TCKChronoLocalDateTime.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider="calendars") public void test_badTemporalFieldChrono(Chronology chrono) { LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); TemporalField adjuster = new FixedTemporalField(cdt2); if (chrono != chrono2) { try { cdt.with(adjuster, 1); Assert.fail("TemporalField doWith() should have thrown a ClassCastException" + cdt.getClass() + ", can not be cast to " + cdt2.getClass()); } catch (ClassCastException cce) { // Expected exception; not an error } } else { // Same chronology, ChronoLocalDateTime<?> result = cdt.with(adjuster, 1); assertEquals(result, cdt2, "TemporalField doWith() failed to replace date"); } } }
Example 9
Source File: TCKChronoLocalDateTime.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider="calendars") public void test_badWithAdjusterChrono(Chronology chrono) { LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); TemporalAdjuster adjuster = new FixedAdjuster(cdt2); if (chrono != chrono2) { try { cdt.with(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.with(adjuster); assertEquals(result, cdt2, "WithAdjuster failed to replace date"); } } }
Example 10
Source File: TCKChronoLocalDateTime.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider="calendars") public void test_badWithAdjusterChrono(Chronology chrono) { LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); TemporalAdjuster adjuster = new FixedAdjuster(cdt2); if (chrono != chrono2) { try { cdt.with(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.with(adjuster); assertEquals(result, cdt2, "WithAdjuster failed to replace date"); } } }
Example 11
Source File: TCKChronoLocalDateTime.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider="calendars") public void test_badWithAdjusterChrono(Chronology chrono) { LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); TemporalAdjuster adjuster = new FixedAdjuster(cdt2); if (chrono != chrono2) { try { cdt.with(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.with(adjuster); assertEquals(result, cdt2, "WithAdjuster failed to replace date"); } } }
Example 12
Source File: TCKChronoLocalDateTime.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider="calendars") public void test_badTemporalFieldChrono(Chronology chrono) { LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); TemporalField adjuster = new FixedTemporalField(cdt2); if (chrono != chrono2) { try { cdt.with(adjuster, 1); Assert.fail("TemporalField doWith() should have thrown a ClassCastException" + cdt.getClass() + ", can not be cast to " + cdt2.getClass()); } catch (ClassCastException cce) { // Expected exception; not an error } } else { // Same chronology, ChronoLocalDateTime<?> result = cdt.with(adjuster, 1); assertEquals(result, cdt2, "TemporalField doWith() failed to replace date"); } } }
Example 13
Source File: TCKChronoLocalDateTime.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider="calendars") public void test_badWithAdjusterChrono(Chronology chrono) { LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); TemporalAdjuster adjuster = new FixedAdjuster(cdt2); if (chrono != chrono2) { try { cdt.with(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.with(adjuster); assertEquals(result, cdt2, "WithAdjuster failed to replace date"); } } }
Example 14
Source File: TCKChronoLocalDateTime.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider="calendars") public void test_badTemporalFieldChrono(Chronology chrono) { LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); TemporalField adjuster = new FixedTemporalField(cdt2); if (chrono != chrono2) { try { cdt.with(adjuster, 1); Assert.fail("TemporalField doWith() should have thrown a ClassCastException" + cdt.getClass() + ", can not be cast to " + cdt2.getClass()); } catch (ClassCastException cce) { // Expected exception; not an error } } else { // Same chronology, ChronoLocalDateTime<?> result = cdt.with(adjuster, 1); assertEquals(result, cdt2, "TemporalField doWith() failed to replace date"); } } }
Example 15
Source File: TCKChronoLocalDateTime.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider="calendars") public void test_badWithAdjusterChrono(Chronology chrono) { LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); TemporalAdjuster adjuster = new FixedAdjuster(cdt2); if (chrono != chrono2) { try { cdt.with(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.with(adjuster); assertEquals(result, cdt2, "WithAdjuster failed to replace date"); } } }
Example 16
Source File: TCKChronoLocalDateTime.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider="calendars") public void test_badTemporalFieldChrono(Chronology chrono) { LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); TemporalField adjuster = new FixedTemporalField(cdt2); if (chrono != chrono2) { try { cdt.with(adjuster, 1); Assert.fail("TemporalField doWith() should have thrown a ClassCastException" + cdt.getClass() + ", can not be cast to " + cdt2.getClass()); } catch (ClassCastException cce) { // Expected exception; not an error } } else { // Same chronology, ChronoLocalDateTime<?> result = cdt.with(adjuster, 1); assertEquals(result, cdt2, "TemporalField doWith() failed to replace date"); } } }
Example 17
Source File: TCKChronoLocalDateTime.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider="calendars") public void test_badTemporalFieldChrono(Chronology chrono) { LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); TemporalField adjuster = new FixedTemporalField(cdt2); if (chrono != chrono2) { try { cdt.with(adjuster, 1); Assert.fail("TemporalField doWith() should have thrown a ClassCastException" + cdt.getClass() + ", can not be cast to " + cdt2.getClass()); } catch (ClassCastException cce) { // Expected exception; not an error } } else { // Same chronology, ChronoLocalDateTime<?> result = cdt.with(adjuster, 1); assertEquals(result, cdt2, "TemporalField doWith() failed to replace date"); } } }
Example 18
Source File: TCKChronoLocalDateTime.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider="calendars") public void test_badTemporalFieldChrono(Chronology chrono) { LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); TemporalField adjuster = new FixedTemporalField(cdt2); if (chrono != chrono2) { try { cdt.with(adjuster, 1); Assert.fail("TemporalField doWith() should have thrown a ClassCastException" + cdt.getClass() + ", can not be cast to " + cdt2.getClass()); } catch (ClassCastException cce) { // Expected exception; not an error } } else { // Same chronology, ChronoLocalDateTime<?> result = cdt.with(adjuster, 1); assertEquals(result, cdt2, "TemporalField doWith() failed to replace date"); } } }
Example 19
Source File: TCKChronoLocalDateTime.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider="calendars") public void test_badWithAdjusterChrono(Chronology chrono) { LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); TemporalAdjuster adjuster = new FixedAdjuster(cdt2); if (chrono != chrono2) { try { cdt.with(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.with(adjuster); assertEquals(result, cdt2, "WithAdjuster failed to replace date"); } } }
Example 20
Source File: TCKChronoLocalDateTime.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider="calendars") public void test_badTemporalFieldChrono(Chronology chrono) { LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); TemporalField adjuster = new FixedTemporalField(cdt2); if (chrono != chrono2) { try { cdt.with(adjuster, 1); Assert.fail("TemporalField doWith() should have thrown a ClassCastException" + cdt.getClass() + ", can not be cast to " + cdt2.getClass()); } catch (ClassCastException cce) { // Expected exception; not an error } } else { // Same chronology, ChronoLocalDateTime<?> result = cdt.with(adjuster, 1); assertEquals(result, cdt2, "TemporalField doWith() failed to replace date"); } } }