Java Code Examples for java.time.temporal.ChronoField#values()
The following examples show how to use
java.time.temporal.ChronoField#values() .
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: MainPanel.java From java-swing-tips with MIT License | 6 votes |
@SuppressWarnings("PMD.CyclomaticComplexity") @Override public Object stringToValue(String text) throws ParseException { // System.out.println("stringToValue:" + text); SpinnerLocalDateTimeModel m = getModel(); try { // LocalDateTime value = LocalDate.parse(text, dateTimeFormatter).atStartOfDay(); TemporalAccessor ta = dateTimeFormatter.parse(text); ChronoLocalDateTime<?> value = m.getLocalDateTime(); // @see https://tips4java.wordpress.com/2015/04/09/temporal-spinners/ for (ChronoField field: ChronoField.values()) { if (field.isSupportedBy(value) && ta.isSupported(field)) { value = field.adjustInto(value, ta.getLong(field)); } } Comparable<ChronoLocalDateTime<?>> min = m.getStart(); Comparable<ChronoLocalDateTime<?>> max = m.getEnd(); if (Objects.nonNull(min) && min.compareTo(value) > 0) { throw new ParseException(text + " is out of range", 0); } else if (Objects.nonNull(max) && max.compareTo(value) < 0) { throw new ParseException(text + " is out of range", 0); } return value; } catch (DateTimeParseException ex) { throw (ParseException) new ParseException(ex.getMessage(), ex.getErrorIndex()).initCause(ex); } }
Example 2
Source File: ZoneOffsetTest.java From j2objc with Apache License 2.0 | 5 votes |
@Test public void test_range_unsupported() { for (ChronoField field : ChronoField.values()) { // Only OFFSET_SECONDS is supported. if (field == ChronoField.OFFSET_SECONDS) { continue; } try { OFFSET_P1.range(field); fail("ZoneOffset.range(" + field + ") should have failed."); } catch (UnsupportedTemporalTypeException expected) { } } }
Example 3
Source File: ZoneOffsetTest.java From j2objc with Apache License 2.0 | 5 votes |
@Test public void test_isSupported() { for (ChronoField field : ChronoField.values()) { // Only OFFSET_SECONDS is supported. assertEquals("isSupported(" + field + ")", field == ChronoField.OFFSET_SECONDS, OFFSET_P1.isSupported(field)); } }
Example 4
Source File: TCKChronoField.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
@Test public void test_valueOf() { for (ChronoField field : ChronoField.values()) { assertEquals(ChronoField.valueOf(field.name()), field); } }
Example 5
Source File: TCKChronoField.java From j2objc with Apache License 2.0 | 4 votes |
@Test public void test_valueOf() { for (ChronoField field : ChronoField.values()) { assertEquals(ChronoField.valueOf(field.name()), field); } }
Example 6
Source File: TCKChronoField.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
@Test public void test_valueOf() { for (ChronoField field : ChronoField.values()) { assertEquals(ChronoField.valueOf(field.name()), field); } }
Example 7
Source File: TCKChronoField.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
@Test public void test_valueOf() { for (ChronoField field : ChronoField.values()) { assertEquals(ChronoField.valueOf(field.name()), field); } }
Example 8
Source File: TCKChronoField.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
@Test public void test_valueOf() { for (ChronoField field : ChronoField.values()) { assertEquals(ChronoField.valueOf(field.name()), field); } }
Example 9
Source File: TCKChronoField.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
@Test public void test_valueOf() { for (ChronoField field : ChronoField.values()) { assertEquals(ChronoField.valueOf(field.name()), field); } }
Example 10
Source File: TCKChronoField.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
@Test public void test_valueOf() { for (ChronoField field : ChronoField.values()) { assertEquals(ChronoField.valueOf(field.name()), field); } }
Example 11
Source File: TCKChronoField.java From hottub with GNU General Public License v2.0 | 4 votes |
@Test public void test_valueOf() { for (ChronoField field : ChronoField.values()) { assertEquals(ChronoField.valueOf(field.name()), field); } }
Example 12
Source File: TCKChronoField.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
@Test public void test_valueOf() { for (ChronoField field : ChronoField.values()) { assertEquals(ChronoField.valueOf(field.name()), field); } }
Example 13
Source File: TCKChronoField.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Test public void test_valueOf() { for (ChronoField field : ChronoField.values()) { assertEquals(ChronoField.valueOf(field.name()), field); } }
Example 14
Source File: TCKChronoField.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
@Test public void test_valueOf() { for (ChronoField field : ChronoField.values()) { assertEquals(ChronoField.valueOf(field.name()), field); } }
Example 15
Source File: TCKChronoField.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
@Test public void test_valueOf() { for (ChronoField field : ChronoField.values()) { assertEquals(ChronoField.valueOf(field.name()), field); } }
Example 16
Source File: TCKChronoField.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
@Test public void test_valueOf() { for (ChronoField field : ChronoField.values()) { assertEquals(ChronoField.valueOf(field.name()), field); } }
Example 17
Source File: TCKChronoField.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Test public void test_valueOf() { for (ChronoField field : ChronoField.values()) { assertEquals(ChronoField.valueOf(field.name()), field); } }