use of java.time.temporal.TemporalAccessor in project jdk8u_jdk by JetBrains.
the class AbstractDateTimeTest method basicTest_get_TemporalField_supported.
//-----------------------------------------------------------------------
// get(TemporalField)
//-----------------------------------------------------------------------
@Test()
public void basicTest_get_TemporalField_supported() {
for (TemporalAccessor sample : samples()) {
for (TemporalField field : validFields()) {
if (sample.range(field).isIntValue()) {
// no exception
sample.get(field);
} else {
try {
sample.get(field);
fail("Failed on " + sample + " " + field);
} catch (DateTimeException ex) {
// expected
}
}
}
}
}
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);
}
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);
}
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);
}
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);
}
Aggregations