use of java.text.Format in project j2objc by google.
the class TCKDateTimeFormatter method test_toFormat_parseObject_String_null.
@Test(expected = NullPointerException.class)
public void test_toFormat_parseObject_String_null() throws Exception {
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
Format format = test.toFormat();
format.parseObject((String) null);
}
use of java.text.Format in project j2objc by google.
the class TCKDateTimeFormatter method test_toFormat_parseObject_String_parseErrorLongText.
@Test(expected = ParseException.class)
public void test_toFormat_parseObject_String_parseErrorLongText() throws Exception {
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
Format format = test.toFormat();
try {
format.parseObject("ONEXXX67890123456789012345678901234567890123456789012345678901234567890123456789");
} catch (DateTimeParseException ex) {
assertEquals(ex.getMessage().contains("ONEXXX6789012345678901234567890123456789012345678901234567890123..."), true);
assertEquals(ex.getParsedString(), "ONEXXX67890123456789012345678901234567890123456789012345678901234567890123456789");
assertEquals(ex.getErrorIndex(), 3);
throw ex;
}
}
use of java.text.Format in project j2objc by google.
the class TCKDateTimeFormatter method test_toFormat_parseObject_StringParsePosition_nullString.
@Test(expected = NullPointerException.class)
public void test_toFormat_parseObject_StringParsePosition_nullString() throws Exception {
// SimpleDateFormat has this behavior
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
Format format = test.toFormat();
ParsePosition pos = new ParsePosition(0);
format.parseObject((String) null, pos);
}
use of java.text.Format in project j2objc by google.
the class TCKDateTimeFormatter method test_toFormat_parseObject_StringParsePosition_invalidPosition_tooBig.
@Test
public void test_toFormat_parseObject_StringParsePosition_invalidPosition_tooBig() throws Exception {
// SimpleDateFormat has this behavior
DateTimeFormatter dtf = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
ParsePosition pos = new ParsePosition(6);
Format test = dtf.toFormat();
assertNull(test.parseObject("ONE30", pos));
assertTrue(pos.getErrorIndex() >= 0);
}
use of java.text.Format in project j2objc by google.
the class TCKDateTimeFormatter method test_toFormat_parseObject_StringParsePosition.
// -----------------------------------------------------------------------
@Test
public void test_toFormat_parseObject_StringParsePosition() 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("ONE30XXX", pos);
assertEquals(pos.getIndex(), 5);
assertEquals(pos.getErrorIndex(), -1);
assertEquals(result.isSupported(DAY_OF_MONTH), true);
assertEquals(result.getLong(DAY_OF_MONTH), 30L);
}
Aggregations