use of java.text.Format in project phoenix by apache.
the class ExplainTable method appendPKColumnValue.
private void appendPKColumnValue(StringBuilder buf, byte[] range, Boolean isNull, int slotIndex, boolean changeViewIndexId) {
if (Boolean.TRUE.equals(isNull)) {
buf.append("null");
return;
}
if (Boolean.FALSE.equals(isNull)) {
buf.append("not null");
return;
}
if (range.length == 0) {
buf.append('*');
return;
}
ScanRanges scanRanges = context.getScanRanges();
PDataType type = scanRanges.getSchema().getField(slotIndex).getDataType();
SortOrder sortOrder = tableRef.getTable().getPKColumns().get(slotIndex).getSortOrder();
if (sortOrder == SortOrder.DESC) {
buf.append('~');
ImmutableBytesWritable ptr = new ImmutableBytesWritable(range);
type.coerceBytes(ptr, type, sortOrder, SortOrder.getDefault());
range = ptr.get();
}
if (changeViewIndexId) {
Short s = (Short) type.toObject(range);
s = (short) (s + (-Short.MAX_VALUE));
buf.append(s.toString());
} else {
Format formatter = context.getConnection().getFormatter(type);
buf.append(type.toStringLiteral(range, formatter));
}
}
use of java.text.Format in project phoenix by apache.
the class ToNumberParseNode method create.
@Override
public FunctionExpression create(List<Expression> children, StatementContext context) throws SQLException {
PDataType dataType = children.get(0).getDataType();
// either date or number format string
String formatString = (String) ((LiteralExpression) children.get(1)).getValue();
Format formatter = null;
FunctionArgumentType type;
if (dataType.isCoercibleTo(PTimestamp.INSTANCE)) {
if (formatString == null) {
formatString = context.getDateFormat();
formatter = context.getDateFormatter();
} else {
formatter = FunctionArgumentType.TEMPORAL.getFormatter(formatString);
}
type = FunctionArgumentType.TEMPORAL;
} else if (dataType.isCoercibleTo(PChar.INSTANCE)) {
if (formatString != null) {
formatter = FunctionArgumentType.CHAR.getFormatter(formatString);
}
type = FunctionArgumentType.CHAR;
} else {
throw new SQLException(dataType + " type is unsupported for TO_NUMBER(). Numeric and temporal types are supported.");
}
return new ToNumberFunction(children, type, formatString, formatter);
}
use of java.text.Format in project phoenix by apache.
the class UpgradeUtil method getSysCatalogSnapshotName.
public static final String getSysCatalogSnapshotName(long currentSystemTableTimestamp) {
String tableString = SYSTEM_CATALOG_NAME;
Format formatter = new SimpleDateFormat("yyyyMMddHHmmss");
String date = formatter.format(new Date(System.currentTimeMillis()));
String upgradingFrom = getVersion(currentSystemTableTimestamp);
return "SNAPSHOT_" + tableString + "_" + upgradingFrom + "_TO_" + CURRENT_CLIENT_VERSION + "_" + date;
}
use of java.text.Format in project jdk8u_jdk by JetBrains.
the class TCKDateTimeFormatter method test_toFormat_parseObject_String_parseErrorLongText.
@Test(expectedExceptions = 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 jdk8u_jdk by JetBrains.
the class TCKDateTimeFormatter method test_toFormat_parseObject_StringParsePosition_dateTimeError.
@Test(expectedExceptions = ParseException.class)
public void test_toFormat_parseObject_StringParsePosition_dateTimeError() throws Exception {
Format format = DATE_FORMATTER.toFormat(LocalDate::from);
format.parseObject("ONE2012 07 32");
}
Aggregations