Search in sources :

Example 91 with TemporalAccessor

use of java.time.temporal.TemporalAccessor in project jdk8u_jdk by JetBrains.

the class TestDateTimeParsing method test_parse_instantZones_ZDT.

@Test(dataProvider = "instantZones")
public void test_parse_instantZones_ZDT(DateTimeFormatter formatter, String text, ZonedDateTime expected) {
    TemporalAccessor actual = formatter.parse(text);
    assertEquals(ZonedDateTime.from(actual), expected);
}
Also used : TemporalAccessor(java.time.temporal.TemporalAccessor) Test(org.testng.annotations.Test)

Example 92 with TemporalAccessor

use of java.time.temporal.TemporalAccessor in project jdk8u_jdk by JetBrains.

the class TestDateTimeParsing method test_parse_instantZones_supported.

@Test(dataProvider = "instantZones")
public void test_parse_instantZones_supported(DateTimeFormatter formatter, String text, ZonedDateTime expected) {
    TemporalAccessor actual = formatter.parse(text);
    assertEquals(actual.isSupported(INSTANT_SECONDS), true);
    assertEquals(actual.isSupported(EPOCH_DAY), true);
    assertEquals(actual.isSupported(SECOND_OF_DAY), true);
    assertEquals(actual.isSupported(NANO_OF_SECOND), true);
    assertEquals(actual.isSupported(MICRO_OF_SECOND), true);
    assertEquals(actual.isSupported(MILLI_OF_SECOND), true);
}
Also used : TemporalAccessor(java.time.temporal.TemporalAccessor) Test(org.testng.annotations.Test)

Example 93 with TemporalAccessor

use of java.time.temporal.TemporalAccessor in project jdk8u_jdk by JetBrains.

the class TestDateTimeFormatter method test_parsed_toString_resolvedDateTime.

@Test
public void test_parsed_toString_resolvedDateTime() {
    DateTimeFormatter f = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
    TemporalAccessor temporal = f.parse("2010-06-30 11:30:56");
    String msg = temporal.toString();
    assertTrue(msg.contains("2010-06-30"), msg);
    assertTrue(msg.contains("11:30:56"), msg);
}
Also used : TemporalAccessor(java.time.temporal.TemporalAccessor) DateTimeFormatter(java.time.format.DateTimeFormatter) Test(org.testng.annotations.Test)

Example 94 with TemporalAccessor

use of java.time.temporal.TemporalAccessor in project jdk8u_jdk by JetBrains.

the class TestDateTimeParsing method test_parse_instantNoZone_supported.

@Test(dataProvider = "instantNoZone")
public void test_parse_instantNoZone_supported(DateTimeFormatter formatter, String text, Instant expected) {
    TemporalAccessor actual = formatter.parse(text);
    assertEquals(actual.isSupported(INSTANT_SECONDS), true);
    assertEquals(actual.isSupported(EPOCH_DAY), false);
    assertEquals(actual.isSupported(SECOND_OF_DAY), false);
    assertEquals(actual.isSupported(NANO_OF_SECOND), true);
    assertEquals(actual.isSupported(MICRO_OF_SECOND), true);
    assertEquals(actual.isSupported(MILLI_OF_SECOND), true);
}
Also used : TemporalAccessor(java.time.temporal.TemporalAccessor) Test(org.testng.annotations.Test)

Example 95 with TemporalAccessor

use of java.time.temporal.TemporalAccessor in project jdk8u_jdk by JetBrains.

the class TestDateTimeParsing method test_parse_instantZones_Instant.

@Test(dataProvider = "instantZones")
public void test_parse_instantZones_Instant(DateTimeFormatter formatter, String text, ZonedDateTime expected) {
    TemporalAccessor actual = formatter.parse(text);
    assertEquals(Instant.from(actual), expected.toInstant());
}
Also used : TemporalAccessor(java.time.temporal.TemporalAccessor) Test(org.testng.annotations.Test)

Aggregations

TemporalAccessor (java.time.temporal.TemporalAccessor)235 Test (org.testng.annotations.Test)189 DateTimeFormatter (java.time.format.DateTimeFormatter)103 ParsePosition (java.text.ParsePosition)82 DateTimeFormatterBuilder (java.time.format.DateTimeFormatterBuilder)61 DateTimeException (java.time.DateTimeException)32 DateTimeParseException (java.time.format.DateTimeParseException)24 LocalDate (java.time.LocalDate)14 TemporalField (java.time.temporal.TemporalField)13 ZonedDateTime (java.time.ZonedDateTime)7 LocalTime (java.time.LocalTime)6 InvalidParametersEvent (org.kie.dmn.feel.runtime.events.InvalidParametersEvent)6 Instant (java.time.Instant)5 ZoneId (java.time.ZoneId)5 ChronoLocalDate (java.time.chrono.ChronoLocalDate)5 Chronology (java.time.chrono.Chronology)5 ResolverStyle (java.time.format.ResolverStyle)5 Test (org.junit.Test)5 LocalDateTime (java.time.LocalDateTime)4 ChronoZonedDateTime (java.time.chrono.ChronoZonedDateTime)4