use of java.text.Format 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.text.Format 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);
}
use of java.text.Format in project jdk8u_jdk by JetBrains.
the class TCKDateTimeFormatter method test_toFormat_parseObject_StringParsePosition_nullString.
@Test(expectedExceptions = 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 jdk8u_jdk by JetBrains.
the class TCKDateTimeFormatter method test_toFormat_format_notTemporal.
@Test(expectedExceptions = IllegalArgumentException.class)
public void test_toFormat_format_notTemporal() throws Exception {
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
Format format = test.toFormat();
format.format("Not a Temporal");
}
use of java.text.Format in project phoenix by apache.
the class PhoenixResultSet method getString.
@Override
public String getString(int columnIndex) throws SQLException {
checkCursorState();
// Get the value using the expected type instead of trying to coerce to VARCHAR.
// We can't coerce using our formatter because we don't have enough context in PDataType.
ColumnProjector projector = rowProjector.getColumnProjector(columnIndex - 1);
PDataType type = projector.getExpression().getDataType();
Object value = projector.getValue(currentRow, type, ptr);
if (wasNull = (value == null)) {
return null;
}
// Run Object through formatter to get String.
// This provides a simple way of getting a reasonable string representation
// for types like DATE and TIME
Format formatter = statement.getFormatter(type);
return formatter == null ? value.toString() : formatter.format(value);
}
Aggregations