Java Code Examples for java.time.Year#from()
The following examples show how to use
java.time.Year#from() .
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: JavaTimeConverterServiceTest.java From SimpleFlatMapper with MIT License | 6 votes |
@Test public void testObjectToYear() throws Exception { ZoneId zoneId = ZONE_ID; Date now = new Date(); Year year = Year.from(now.toInstant().atZone(zoneId)); testObjectToYear(null, null); testObjectToYear(year, year); testObjectToYear(year.atMonth(6).atEndOfMonth().atTime(1, 0).atZone(zoneId), year); testObjectToYear(now, year); testObjectToYear(year.getValue(), year); try { testObjectToYear("a string", year); fail(); } catch (IllegalArgumentException e) { // expected } }
Example 2
Source File: FHIRPathUtil.java From FHIR with Apache License 2.0 | 6 votes |
public static TemporalAccessor getTemporalAccessor(Temporal temporal, Class<?> targetType) { if (temporal.getClass().equals(targetType)) { return temporal; } if (Year.class.equals(targetType)) { return Year.from(temporal); } else if (YearMonth.class.equals(targetType)) { return YearMonth.from(temporal); } else if (LocalDate.class.equals(targetType)) { return LocalDate.from(temporal); } else if (LocalDateTime.class.equals(targetType)) { return LocalDateTime.from(temporal); } else if (ZonedDateTime.class.equals(targetType)){ return ZonedDateTime.from(temporal); } else if (LocalTime.class.equals(targetType)) { return LocalTime.from(temporal); } throw new IllegalArgumentException(); }
Example 3
Source File: TCKYear.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=NullPointerException.class) public void test_from_TemporalAccessor_null() { Year.from((TemporalAccessor) null); }
Example 4
Source File: TCKYear.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=DateTimeException.class) public void test_from_TemporalAccessor_invalid_noDerive() { Year.from(LocalTime.of(12, 30)); }
Example 5
Source File: TCKYear.java From j2objc with Apache License 2.0 | 4 votes |
@Test(expected=DateTimeException.class) public void test_from_TemporalAccessor_invalid_noDerive() { Year.from(LocalTime.of(12, 30)); }
Example 6
Source File: TCKYear.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=DateTimeException.class) public void test_from_TemporalAccessor_invalid_noDerive() { Year.from(LocalTime.of(12, 30)); }
Example 7
Source File: TCKYear.java From hottub with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=NullPointerException.class) public void test_from_TemporalAccessor_null() { Year.from((TemporalAccessor) null); }
Example 8
Source File: TCKYear.java From hottub with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=DateTimeException.class) public void test_from_TemporalAccessor_invalid_noDerive() { Year.from(LocalTime.of(12, 30)); }
Example 9
Source File: TCKYear.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=NullPointerException.class) public void test_from_TemporalAccessor_null() { Year.from((TemporalAccessor) null); }
Example 10
Source File: TCKYear.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=NullPointerException.class) public void test_from_TemporalAccessor_null() { Year.from((TemporalAccessor) null); }
Example 11
Source File: TCKYear.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=NullPointerException.class) public void test_from_TemporalAccessor_null() { Year.from((TemporalAccessor) null); }
Example 12
Source File: TCKYear.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=DateTimeException.class) public void test_from_TemporalAccessor_invalid_noDerive() { Year.from(LocalTime.of(12, 30)); }
Example 13
Source File: TCKYear.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=DateTimeException.class) public void test_from_TemporalAccessor_invalid_noDerive() { Year.from(LocalTime.of(12, 30)); }
Example 14
Source File: TCKYear.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=NullPointerException.class) public void test_from_TemporalAccessor_null() { Year.from((TemporalAccessor) null); }
Example 15
Source File: TCKYear.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=NullPointerException.class) public void test_from_TemporalAccessor_null() { Year.from((TemporalAccessor) null); }
Example 16
Source File: TCKYear.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=DateTimeException.class) public void test_from_TemporalAccessor_invalid_noDerive() { Year.from(LocalTime.of(12, 30)); }
Example 17
Source File: TCKYear.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=NullPointerException.class) public void test_from_TemporalAccessor_null() { Year.from((TemporalAccessor) null); }
Example 18
Source File: TCKYear.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=DateTimeException.class) public void test_from_TemporalAccessor_invalid_noDerive() { Year.from(LocalTime.of(12, 30)); }
Example 19
Source File: TCKYear.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=NullPointerException.class) public void test_from_TemporalAccessor_null() { Year.from((TemporalAccessor) null); }
Example 20
Source File: TCKYear.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=NullPointerException.class) public void test_from_TemporalAccessor_null() { Year.from((TemporalAccessor) null); }