use of java.time.format.DateTimeFormatter in project jdk8u_jdk by JetBrains.
the class TCKDateTimeFormatter method test_parseBest_firstOption.
//-----------------------------------------------------------------------
@Test
public void test_parseBest_firstOption() throws Exception {
DateTimeFormatter test = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm[XXX]");
TemporalAccessor result = test.parseBest("2011-06-30 12:30+03:00", ZonedDateTime::from, LocalDateTime::from);
LocalDateTime ldt = LocalDateTime.of(2011, 6, 30, 12, 30);
assertEquals(result, ZonedDateTime.of(ldt, ZoneOffset.ofHours(3)));
}
use of java.time.format.DateTimeFormatter in project jdk8u_jdk by JetBrains.
the class TCKDateTimeFormatter method test_withZone.
//-----------------------------------------------------------------------
@Test
public void test_withZone() {
DateTimeFormatter test = fmt;
assertEquals(test.getZone(), null);
test = test.withZone(ZoneId.of("Europe/Paris"));
assertEquals(test.getZone(), ZoneId.of("Europe/Paris"));
test = test.withZone(ZoneOffset.UTC);
assertEquals(test.getZone(), ZoneOffset.UTC);
test = test.withZone(null);
assertEquals(test.getZone(), null);
}
use of java.time.format.DateTimeFormatter in project jdk8u_jdk by JetBrains.
the class TCKDateTimeFormatter method test_withLocale_null.
@Test(expectedExceptions = NullPointerException.class)
public void test_withLocale_null() {
DateTimeFormatter base = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
base.withLocale((Locale) null);
}
use of java.time.format.DateTimeFormatter in project jdk8u_jdk by JetBrains.
the class TCKDateTimeFormatter method test_toFormat_parseObject_StringParsePosition_nullParsePosition.
@Test(expectedExceptions = NullPointerException.class)
public void test_toFormat_parseObject_StringParsePosition_nullParsePosition() throws Exception {
// SimpleDateFormat has this behavior
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
Format format = test.toFormat();
format.parseObject("ONE30", (ParsePosition) null);
}
use of java.time.format.DateTimeFormatter in project jdk8u_jdk by JetBrains.
the class TCKDateTimeFormatter method test_toFormat_parseObject_StringParsePosition_parseError.
@Test
public void test_toFormat_parseObject_StringParsePosition_parseError() throws Exception {
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
Format format = test.toFormat();
ParsePosition pos = new ParsePosition(0);
TemporalAccessor result = (TemporalAccessor) format.parseObject("ONEXXX", pos);
// TODO: is this right?
assertEquals(pos.getIndex(), 0);
assertEquals(pos.getErrorIndex(), 3);
assertEquals(result, null);
}
Aggregations