Search in sources :

Example 46 with DateTimeFormatter

use of java.time.format.DateTimeFormatter in project jdk8u_jdk by JetBrains.

the class TCKDateTimeFormatter method test_format_TemporalAccessor_simple.

//-----------------------------------------------------------------------
@Test
public void test_format_TemporalAccessor_simple() {
    DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
    String result = test.format(LocalDate.of(2008, 6, 30));
    assertEquals(result, "ONE30");
}
Also used : DateTimeFormatter(java.time.format.DateTimeFormatter) Test(org.testng.annotations.Test)

Example 47 with DateTimeFormatter

use of java.time.format.DateTimeFormatter in project jdk8u_jdk by JetBrains.

the class TCKDateTimeFormatter method test_toFormat_parseObject_StringParsePosition_invalidPosition_tooSmall.

@Test
public void test_toFormat_parseObject_StringParsePosition_invalidPosition_tooSmall() throws Exception {
    // SimpleDateFormat throws StringIndexOutOfBoundException
    DateTimeFormatter dtf = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
    ParsePosition pos = new ParsePosition(-1);
    Format test = dtf.toFormat();
    assertNull(test.parseObject("ONE30", pos));
    assertTrue(pos.getErrorIndex() >= 0);
}
Also used : Format(java.text.Format) DateTimeFormatter(java.time.format.DateTimeFormatter) ParsePosition(java.text.ParsePosition) Test(org.testng.annotations.Test)

Example 48 with DateTimeFormatter

use of java.time.format.DateTimeFormatter in project jdk8u_jdk by JetBrains.

the class TCKDateTimeFormatter method test_parse_Query_String_nullRule.

@Test(expectedExceptions = NullPointerException.class)
public void test_parse_Query_String_nullRule() throws Exception {
    DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
    test.parse("30", (TemporalQuery<?>) null);
}
Also used : DateTimeFormatter(java.time.format.DateTimeFormatter) Test(org.testng.annotations.Test)

Example 49 with DateTimeFormatter

use of java.time.format.DateTimeFormatter in project jdk8u_jdk by JetBrains.

the class TCKDateTimeFormatter method test_parse_CharSequence_ParsePosition_nullParsePosition.

@Test(expectedExceptions = NullPointerException.class)
public void test_parse_CharSequence_ParsePosition_nullParsePosition() {
    DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
    test.parse("Text", (ParsePosition) null);
}
Also used : DateTimeFormatter(java.time.format.DateTimeFormatter) Test(org.testng.annotations.Test)

Example 50 with DateTimeFormatter

use of java.time.format.DateTimeFormatter in project jdk8u_jdk by JetBrains.

the class TCKDateTimeFormatter method test_parseUnresolved_StringParsePosition_invalidPosition.

@Test(expectedExceptions = IndexOutOfBoundsException.class)
public void test_parseUnresolved_StringParsePosition_invalidPosition() {
    DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
    ParsePosition pos = new ParsePosition(6);
    test.parseUnresolved("ONE30", pos);
}
Also used : DateTimeFormatter(java.time.format.DateTimeFormatter) ParsePosition(java.text.ParsePosition) Test(org.testng.annotations.Test)

Aggregations

DateTimeFormatter (java.time.format.DateTimeFormatter)905 Test (org.junit.Test)297 Test (org.testng.annotations.Test)272 DateTimeFormatterBuilder (java.time.format.DateTimeFormatterBuilder)229 TemporalAccessor (java.time.temporal.TemporalAccessor)205 LocalDate (java.time.LocalDate)142 ParsePosition (java.text.ParsePosition)94 LocalDateTime (java.time.LocalDateTime)92 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)85 ZonedDateTime (java.time.ZonedDateTime)71 Instant (java.time.Instant)53 DateTimeParseException (java.time.format.DateTimeParseException)50 ZoneId (java.time.ZoneId)39 TemporalField (java.time.temporal.TemporalField)39 WeekFields (java.time.temporal.WeekFields)36 AbstractTCKTest (tck.java.time.AbstractTCKTest)36 DateTimeException (java.time.DateTimeException)34 IOException (java.io.IOException)26 Format (java.text.Format)26 LocalTime (java.time.LocalTime)25