Java Code Examples for java.time.Year#now()
The following examples show how to use
java.time.Year#now() .
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: TCKYear.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Test public void now() { Year expected = Year.now(Clock.systemDefaultZone()); Year test = Year.now(); for (int i = 0; i < 100; i++) { if (expected.equals(test)) { return; } expected = Year.now(Clock.systemDefaultZone()); test = Year.now(); } assertEquals(test, expected); }
Example 2
Source File: TCKYear.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Test public void now_ZoneId() { ZoneId zone = ZoneId.of("UTC+01:02:03"); Year expected = Year.now(Clock.system(zone)); Year test = Year.now(zone); for (int i = 0; i < 100; i++) { if (expected.equals(test)) { return; } expected = Year.now(Clock.system(zone)); test = Year.now(zone); } assertEquals(test, expected); }
Example 3
Source File: TCKYear.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@Test public void now() { Year expected = Year.now(Clock.systemDefaultZone()); Year test = Year.now(); for (int i = 0; i < 100; i++) { if (expected.equals(test)) { return; } expected = Year.now(Clock.systemDefaultZone()); test = Year.now(); } assertEquals(test, expected); }
Example 4
Source File: SettableDataSetterFactoryTest.java From SimpleFlatMapper with MIT License | 5 votes |
@Test public void testJava8TimeYear() throws Exception { Setter<SettableByIndexData, Year> setter = factory.getSetter(newPM(Year.class, DataType.date())); Year ldt = Year.now(); setter.set(statement, ldt); setter.set(statement, null); verify(statement).setDate(0, com.datastax.driver.core.LocalDate.fromYearMonthDay(ldt.getValue(), 1, 1)); verify(statement).setToNull(0); }
Example 5
Source File: TCKYear.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
@Test public void now_ZoneId() { ZoneId zone = ZoneId.of("UTC+01:02:03"); Year expected = Year.now(Clock.system(zone)); Year test = Year.now(zone); for (int i = 0; i < 100; i++) { if (expected.equals(test)) { return; } expected = Year.now(Clock.system(zone)); test = Year.now(zone); } assertEquals(test, expected); }
Example 6
Source File: TCKYear.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Test public void now_ZoneId() { ZoneId zone = ZoneId.of("UTC+01:02:03"); Year expected = Year.now(Clock.system(zone)); Year test = Year.now(zone); for (int i = 0; i < 100; i++) { if (expected.equals(test)) { return; } expected = Year.now(Clock.system(zone)); test = Year.now(zone); } assertEquals(test, expected); }
Example 7
Source File: TCKYear.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@Test public void now_Clock() { Instant instant = OffsetDateTime.of(LocalDate.of(2010, 12, 31), LocalTime.of(0, 0), ZoneOffset.UTC).toInstant(); Clock clock = Clock.fixed(instant, ZoneOffset.UTC); Year test = Year.now(clock); assertEquals(test.getValue(), 2010); }
Example 8
Source File: TCKYear.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Test public void now_Clock() { Instant instant = OffsetDateTime.of(LocalDate.of(2010, 12, 31), LocalTime.of(0, 0), ZoneOffset.UTC).toInstant(); Clock clock = Clock.fixed(instant, ZoneOffset.UTC); Year test = Year.now(clock); assertEquals(test.getValue(), 2010); }
Example 9
Source File: TCKYear.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Test public void now_Clock() { Instant instant = OffsetDateTime.of(LocalDate.of(2010, 12, 31), LocalTime.of(0, 0), ZoneOffset.UTC).toInstant(); Clock clock = Clock.fixed(instant, ZoneOffset.UTC); Year test = Year.now(clock); assertEquals(test.getValue(), 2010); }
Example 10
Source File: TCKYear.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Test public void now() { Year expected = Year.now(Clock.systemDefaultZone()); Year test = Year.now(); for (int i = 0; i < 100; i++) { if (expected.equals(test)) { return; } expected = Year.now(Clock.systemDefaultZone()); test = Year.now(); } assertEquals(test, expected); }
Example 11
Source File: TCKYear.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Test public void now() { Year expected = Year.now(Clock.systemDefaultZone()); Year test = Year.now(); for (int i = 0; i < 100; i++) { if (expected.equals(test)) { return; } expected = Year.now(Clock.systemDefaultZone()); test = Year.now(); } assertEquals(test, expected); }
Example 12
Source File: TCKYear.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
@Test public void now() { Year expected = Year.now(Clock.systemDefaultZone()); Year test = Year.now(); for (int i = 0; i < 100; i++) { if (expected.equals(test)) { return; } expected = Year.now(Clock.systemDefaultZone()); test = Year.now(); } assertEquals(test, expected); }
Example 13
Source File: TCKYear.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@Test public void now_ZoneId() { ZoneId zone = ZoneId.of("UTC+01:02:03"); Year expected = Year.now(Clock.system(zone)); Year test = Year.now(zone); for (int i = 0; i < 100; i++) { if (expected.equals(test)) { return; } expected = Year.now(Clock.system(zone)); test = Year.now(zone); } assertEquals(test, expected); }
Example 14
Source File: PDTFactory.java From ph-commons with Apache License 2.0 | 4 votes |
@Nonnull public static Year getCurrentYearObj () { return Year.now (_getZoneId ()); }
Example 15
Source File: TCKYear.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=NullPointerException.class) public void now_ZoneId_nullZoneId() { Year.now((ZoneId) null); }
Example 16
Source File: GraphSONMapperTest.java From tinkerpop with Apache License 2.0 | 4 votes |
@Test public void shouldHandleYear()throws Exception { final Year o = Year.now(); final String json = mapper.writeValueAsString(o); assertEquals("\"" + o.toString() + "\"", json); }
Example 17
Source File: TCKYear.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=NullPointerException.class) public void now_Clock_nullClock() { Year.now((Clock) null); }
Example 18
Source File: GraphSONMapperEmbeddedTypeTest.java From tinkerpop with Apache License 2.0 | 4 votes |
@Test public void shouldHandleYear() throws Exception { final Year o = Year.now(); assertEquals(o, serializeDeserialize(mapper, o, Year.class)); }
Example 19
Source File: TCKYear.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=NullPointerException.class) public void now_Clock_nullClock() { Year.now((Clock) null); }
Example 20
Source File: TCKYear.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=NullPointerException.class) public void now_ZoneId_nullZoneId() { Year.now((ZoneId) null); }