Java Code Examples for java.time.DateTimeException#getMessage()
The following examples show how to use
java.time.DateTimeException#getMessage() .
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: TestDateTimeFormatter.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Test public void test_throws_message_zone() { ZoneId zone = ZoneId.of("Pacific/Honolulu"); DateTimeFormatter fmt = new DateTimeFormatterBuilder().appendChronologyId().toFormatter() .withZone(zone); LocalTime now = LocalTime.now(); try { fmt.format(now); fail("Format using appendChronologyId() should have failed"); } catch (DateTimeException dte) { String msg = dte.getMessage(); // Verify message contains the type that is missing and the temporal value assertTrue(msg.contains("Chronology"), String.format("\"%s\" missing from %s", "Chronology", msg)); assertTrue(msg.contains(zone.toString()), String.format("\"%s\" missing from %s", zone.toString(), msg)); } }
Example 2
Source File: TestDateTimeFormatter.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private void assertGoodErrorDate(Function<TemporalAccessor, Object> function, String expectedText) { DateTimeFormatter f = DateTimeFormatter.ofPattern("yyyy-mm-dd"); TemporalAccessor temporal = f.parse("2010-06-30"); try { function.apply(temporal); fail("Should have failed"); } catch (DateTimeException ex) { String msg = ex.getMessage(); assertTrue(msg.contains(expectedText), msg); assertTrue(msg.contains("Year"), msg); assertTrue(msg.contains("MinuteOfHour"), msg); assertTrue(msg.contains("DayOfMonth"), msg); } }
Example 3
Source File: TestDateTimeFormatter.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private void assertGoodErrorDate(Function<TemporalAccessor, Object> function, String expectedText) { DateTimeFormatter f = DateTimeFormatter.ofPattern("yyyy-mm-dd"); TemporalAccessor temporal = f.parse("2010-06-30"); try { function.apply(temporal); fail("Should have failed"); } catch (DateTimeException ex) { String msg = ex.getMessage(); assertTrue(msg.contains(expectedText), msg); assertTrue(msg.contains("Year"), msg); assertTrue(msg.contains("MinuteOfHour"), msg); assertTrue(msg.contains("DayOfMonth"), msg); } }
Example 4
Source File: TestDateTimeFormatter.java From hottub with GNU General Public License v2.0 | 5 votes |
private void assertGoodErrorTime(Function<TemporalAccessor, Object> function, String expectedText) { DateTimeFormatter f = DateTimeFormatter.ofPattern("HH:MM:ss"); TemporalAccessor temporal = f.parse("11:30:56"); try { function.apply(temporal); fail("Should have failed"); } catch (DateTimeException ex) { String msg = ex.getMessage(); assertTrue(msg.contains(expectedText), msg); assertTrue(msg.contains("HourOfDay"), msg); assertTrue(msg.contains("MonthOfYear"), msg); assertTrue(msg.contains("SecondOfMinute"), msg); } }
Example 5
Source File: TestDateTimeFormatter.java From hottub with GNU General Public License v2.0 | 5 votes |
private void assertGoodErrorDate(Function<TemporalAccessor, Object> function, String expectedText) { DateTimeFormatter f = DateTimeFormatter.ofPattern("yyyy-mm-dd"); TemporalAccessor temporal = f.parse("2010-06-30"); try { function.apply(temporal); fail("Should have failed"); } catch (DateTimeException ex) { String msg = ex.getMessage(); assertTrue(msg.contains(expectedText), msg); assertTrue(msg.contains("Year"), msg); assertTrue(msg.contains("MinuteOfHour"), msg); assertTrue(msg.contains("DayOfMonth"), msg); } }
Example 6
Source File: TestDateTimeFormatter.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private void assertGoodErrorTime(Function<TemporalAccessor, Object> function, String expectedText) { DateTimeFormatter f = DateTimeFormatter.ofPattern("HH:MM:ss"); TemporalAccessor temporal = f.parse("11:30:56"); try { function.apply(temporal); fail("Should have failed"); } catch (DateTimeException ex) { String msg = ex.getMessage(); assertTrue(msg.contains(expectedText), msg); assertTrue(msg.contains("HourOfDay"), msg); assertTrue(msg.contains("MonthOfYear"), msg); assertTrue(msg.contains("SecondOfMinute"), msg); } }
Example 7
Source File: TestDateTimeFormatter.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private void assertGoodErrorTime(Function<TemporalAccessor, Object> function, String expectedText) { DateTimeFormatter f = DateTimeFormatter.ofPattern("HH:MM:ss"); TemporalAccessor temporal = f.parse("11:30:56"); try { function.apply(temporal); fail("Should have failed"); } catch (DateTimeException ex) { String msg = ex.getMessage(); assertTrue(msg.contains(expectedText), msg); assertTrue(msg.contains("HourOfDay"), msg); assertTrue(msg.contains("MonthOfYear"), msg); assertTrue(msg.contains("SecondOfMinute"), msg); } }
Example 8
Source File: TestDateTimeFormatter.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private void assertGoodErrorTime(Function<TemporalAccessor, Object> function, String expectedText) { DateTimeFormatter f = DateTimeFormatter.ofPattern("HH:MM:ss"); TemporalAccessor temporal = f.parse("11:30:56"); try { function.apply(temporal); fail("Should have failed"); } catch (DateTimeException ex) { String msg = ex.getMessage(); assertTrue(msg.contains(expectedText), msg); assertTrue(msg.contains("HourOfDay"), msg); assertTrue(msg.contains("MonthOfYear"), msg); assertTrue(msg.contains("SecondOfMinute"), msg); } }
Example 9
Source File: TestDateTimeFormatter.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private void assertGoodErrorDate(Function<TemporalAccessor, Object> function, String expectedText) { DateTimeFormatter f = DateTimeFormatter.ofPattern("yyyy-mm-dd"); TemporalAccessor temporal = f.parse("2010-06-30"); try { function.apply(temporal); fail("Should have failed"); } catch (DateTimeException ex) { String msg = ex.getMessage(); assertTrue(msg.contains(expectedText), msg); assertTrue(msg.contains("Year"), msg); assertTrue(msg.contains("MinuteOfHour"), msg); assertTrue(msg.contains("DayOfMonth"), msg); } }
Example 10
Source File: TestDateTimeFormatter.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private void assertGoodErrorTime(Function<TemporalAccessor, Object> function, String expectedText) { DateTimeFormatter f = DateTimeFormatter.ofPattern("HH:MM:ss"); TemporalAccessor temporal = f.parse("11:30:56"); try { function.apply(temporal); fail("Should have failed"); } catch (DateTimeException ex) { String msg = ex.getMessage(); assertTrue(msg.contains(expectedText), msg); assertTrue(msg.contains("HourOfDay"), msg); assertTrue(msg.contains("MonthOfYear"), msg); assertTrue(msg.contains("SecondOfMinute"), msg); } }
Example 11
Source File: TestDateTimeFormatter.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private void assertGoodErrorDate(Function<TemporalAccessor, Object> function, String expectedText) { DateTimeFormatter f = DateTimeFormatter.ofPattern("yyyy-mm-dd"); TemporalAccessor temporal = f.parse("2010-06-30"); try { function.apply(temporal); fail("Should have failed"); } catch (DateTimeException ex) { String msg = ex.getMessage(); assertTrue(msg.contains(expectedText), msg); assertTrue(msg.contains("Year"), msg); assertTrue(msg.contains("MinuteOfHour"), msg); assertTrue(msg.contains("DayOfMonth"), msg); } }
Example 12
Source File: TestDateTimeFormatter.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private void assertGoodErrorTime(Function<TemporalAccessor, Object> function, String expectedText) { DateTimeFormatter f = DateTimeFormatter.ofPattern("HH:MM:ss"); TemporalAccessor temporal = f.parse("11:30:56"); try { function.apply(temporal); fail("Should have failed"); } catch (DateTimeException ex) { String msg = ex.getMessage(); assertTrue(msg.contains(expectedText), msg); assertTrue(msg.contains("HourOfDay"), msg); assertTrue(msg.contains("MonthOfYear"), msg); assertTrue(msg.contains("SecondOfMinute"), msg); } }
Example 13
Source File: TestDateTimeFormatter.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private void assertGoodErrorDate(Function<TemporalAccessor, Object> function, String expectedText) { DateTimeFormatter f = DateTimeFormatter.ofPattern("yyyy-mm-dd"); TemporalAccessor temporal = f.parse("2010-06-30"); try { function.apply(temporal); fail("Should have failed"); } catch (DateTimeException ex) { String msg = ex.getMessage(); assertTrue(msg.contains(expectedText), msg); assertTrue(msg.contains("Year"), msg); assertTrue(msg.contains("MinuteOfHour"), msg); assertTrue(msg.contains("DayOfMonth"), msg); } }
Example 14
Source File: TestDateTimeFormatter.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private void assertGoodErrorTime(Function<TemporalAccessor, Object> function, String expectedText) { DateTimeFormatter f = DateTimeFormatter.ofPattern("HH:MM:ss"); TemporalAccessor temporal = f.parse("11:30:56"); try { function.apply(temporal); fail("Should have failed"); } catch (DateTimeException ex) { String msg = ex.getMessage(); assertTrue(msg.contains(expectedText), msg); assertTrue(msg.contains("HourOfDay"), msg); assertTrue(msg.contains("MonthOfYear"), msg); assertTrue(msg.contains("SecondOfMinute"), msg); } }
Example 15
Source File: TestDateTimeFormatter.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private void assertGoodErrorDate(Function<TemporalAccessor, Object> function, String expectedText) { DateTimeFormatter f = DateTimeFormatter.ofPattern("yyyy-mm-dd"); TemporalAccessor temporal = f.parse("2010-06-30"); try { function.apply(temporal); fail("Should have failed"); } catch (DateTimeException ex) { String msg = ex.getMessage(); assertTrue(msg.contains(expectedText), msg); assertTrue(msg.contains("Year"), msg); assertTrue(msg.contains("MinuteOfHour"), msg); assertTrue(msg.contains("DayOfMonth"), msg); } }
Example 16
Source File: TestDateTimeFormatter.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private void assertGoodErrorTime(Function<TemporalAccessor, Object> function, String expectedText) { DateTimeFormatter f = DateTimeFormatter.ofPattern("HH:MM:ss"); TemporalAccessor temporal = f.parse("11:30:56"); try { function.apply(temporal); fail("Should have failed"); } catch (DateTimeException ex) { String msg = ex.getMessage(); assertTrue(msg.contains(expectedText), msg); assertTrue(msg.contains("HourOfDay"), msg); assertTrue(msg.contains("MonthOfYear"), msg); assertTrue(msg.contains("SecondOfMinute"), msg); } }
Example 17
Source File: TestDateTimeFormatter.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private void assertGoodErrorTime(Function<TemporalAccessor, Object> function, String expectedText) { DateTimeFormatter f = DateTimeFormatter.ofPattern("HH:MM:ss"); TemporalAccessor temporal = f.parse("11:30:56"); try { function.apply(temporal); fail("Should have failed"); } catch (DateTimeException ex) { String msg = ex.getMessage(); assertTrue(msg.contains(expectedText), msg); assertTrue(msg.contains("HourOfDay"), msg); assertTrue(msg.contains("MonthOfYear"), msg); assertTrue(msg.contains("SecondOfMinute"), msg); } }
Example 18
Source File: TestDateTimeFormatter.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private void assertGoodErrorTime(Function<TemporalAccessor, Object> function, String expectedText) { DateTimeFormatter f = DateTimeFormatter.ofPattern("HH:MM:ss"); TemporalAccessor temporal = f.parse("11:30:56"); try { function.apply(temporal); fail("Should have failed"); } catch (DateTimeException ex) { String msg = ex.getMessage(); assertTrue(msg.contains(expectedText), msg); assertTrue(msg.contains("HourOfDay"), msg); assertTrue(msg.contains("MonthOfYear"), msg); assertTrue(msg.contains("SecondOfMinute"), msg); } }
Example 19
Source File: TestDateTimeFormatter.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private void assertGoodErrorDate(Function<TemporalAccessor, Object> function, String expectedText) { DateTimeFormatter f = DateTimeFormatter.ofPattern("yyyy-mm-dd"); TemporalAccessor temporal = f.parse("2010-06-30"); try { function.apply(temporal); fail("Should have failed"); } catch (DateTimeException ex) { String msg = ex.getMessage(); assertTrue(msg.contains(expectedText), msg); assertTrue(msg.contains("Year"), msg); assertTrue(msg.contains("MinuteOfHour"), msg); assertTrue(msg.contains("DayOfMonth"), msg); } }
Example 20
Source File: TestDateTimeFormatter.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private void assertGoodErrorTime(Function<TemporalAccessor, Object> function, String expectedText) { DateTimeFormatter f = DateTimeFormatter.ofPattern("HH:MM:ss"); TemporalAccessor temporal = f.parse("11:30:56"); try { function.apply(temporal); fail("Should have failed"); } catch (DateTimeException ex) { String msg = ex.getMessage(); assertTrue(msg.contains(expectedText), msg); assertTrue(msg.contains("HourOfDay"), msg); assertTrue(msg.contains("MonthOfYear"), msg); assertTrue(msg.contains("SecondOfMinute"), msg); } }