Search in sources :

Example 31 with ParsePosition

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

the class TestZoneOffsetParser method test_parse_exactMatch_UTC_EmptyUTC.

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

Example 32 with ParsePosition

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

the class TestZoneOffsetParser method test_parse_startStringMatch.

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

Example 33 with ParsePosition

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

the class TestZoneOffsetParser method test_parse_exactMatch.

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

Example 34 with ParsePosition

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

the class TestTextParser method test_parse_full_lenient_number_match.

public void test_parse_full_lenient_number_match() throws Exception {
    setStrict(false);
    ParsePosition pos = new ParsePosition(0);
    assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.FULL).parseUnresolved("1", pos).getLong(MONTH_OF_YEAR), 1L);
    assertEquals(pos.getIndex(), 1);
}
Also used : ParsePosition(java.text.ParsePosition)

Example 35 with ParsePosition

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

the class TestTextParser method test_parse_short_lenient_number_match.

public void test_parse_short_lenient_number_match() throws Exception {
    setStrict(false);
    ParsePosition pos = new ParsePosition(0);
    assertEquals(getFormatter(MONTH_OF_YEAR, TextStyle.SHORT).parseUnresolved("1", pos).getLong(MONTH_OF_YEAR), 1L);
    assertEquals(pos.getIndex(), 1);
}
Also used : ParsePosition(java.text.ParsePosition)

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