Search in sources :

Example 26 with ParsePosition

use of java.text.ParsePosition 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)

Example 27 with ParsePosition

use of java.text.ParsePosition in project jdk8u_jdk by JetBrains.

the class TestZoneOffsetParser method test_parse_endStringMatch_EmptyUTC.

@Test(dataProvider = "offsets")
public void test_parse_endStringMatch_EmptyUTC(String pattern, String parse, ZoneOffset expected) throws Exception {
    ParsePosition pos = new ParsePosition(5);
    TemporalAccessor parsed = getFormatter(pattern, "").parseUnresolved("OTHER" + parse, pos);
    assertEquals(pos.getIndex(), parse.length() + 5);
    assertParsed(parsed, expected);
}
Also used : TemporalAccessor(java.time.temporal.TemporalAccessor) ParsePosition(java.text.ParsePosition) Test(org.testng.annotations.Test)

Example 28 with ParsePosition

use of java.text.ParsePosition in project jdk8u_jdk by JetBrains.

the class TestZoneOffsetParser method test_parse_midStringMatch.

@Test(dataProvider = "offsets")
public void test_parse_midStringMatch(String pattern, String parse, ZoneOffset expected) throws Exception {
    ParsePosition pos = new ParsePosition(5);
    TemporalAccessor parsed = getFormatter(pattern, "Z").parseUnresolved("OTHER" + parse + ":OTHER", pos);
    assertEquals(pos.getIndex(), parse.length() + 5);
    assertParsed(parsed, expected);
}
Also used : TemporalAccessor(java.time.temporal.TemporalAccessor) ParsePosition(java.text.ParsePosition) Test(org.testng.annotations.Test)

Example 29 with ParsePosition

use of java.text.ParsePosition in project jdk8u_jdk by JetBrains.

the class TestZoneOffsetParser method test_parse_startStringMatch_UTC.

public void test_parse_startStringMatch_UTC() throws Exception {
    ParsePosition pos = new ParsePosition(0);
    TemporalAccessor parsed = getFormatter("+HH:MM:ss", "Z").parseUnresolved("ZOTHER", pos);
    assertEquals(pos.getIndex(), 1);
    assertParsed(parsed, ZoneOffset.UTC);
}
Also used : TemporalAccessor(java.time.temporal.TemporalAccessor) ParsePosition(java.text.ParsePosition)

Example 30 with ParsePosition

use of java.text.ParsePosition in project jdk8u_jdk by JetBrains.

the class TestZoneOffsetParser method test_parse_midStringMatch_EmptyUTC.

@Test(dataProvider = "offsets")
public void test_parse_midStringMatch_EmptyUTC(String pattern, String parse, ZoneOffset expected) throws Exception {
    ParsePosition pos = new ParsePosition(5);
    TemporalAccessor parsed = getFormatter(pattern, "").parseUnresolved("OTHER" + parse + ":OTHER", pos);
    assertEquals(pos.getIndex(), parse.length() + 5);
    assertParsed(parsed, expected);
}
Also used : TemporalAccessor(java.time.temporal.TemporalAccessor) ParsePosition(java.text.ParsePosition) Test(org.testng.annotations.Test)

Aggregations

ParsePosition (java.text.ParsePosition)704 Test (org.junit.Test)253 Date (java.util.Date)221 TemporalAccessor (java.time.temporal.TemporalAccessor)163 SimpleDateFormat (java.text.SimpleDateFormat)125 DateTimeFormatter (java.time.format.DateTimeFormatter)94 Test (org.testng.annotations.Test)88 ParseException (java.text.ParseException)71 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)49 SimpleDateFormat (android.icu.text.SimpleDateFormat)39 FieldPosition (java.text.FieldPosition)32 Calendar (java.util.Calendar)26 DateTimeFormatterBuilder (java.time.format.DateTimeFormatterBuilder)25 Calendar (android.icu.util.Calendar)23 ULocale (android.icu.util.ULocale)23 NumberFormat (java.text.NumberFormat)23 Format (java.text.Format)21 DecimalFormat (java.text.DecimalFormat)19 GregorianCalendar (android.icu.util.GregorianCalendar)18 JapaneseCalendar (android.icu.util.JapaneseCalendar)17