use of java.sql.Time in project jodd by oblac.
the class SqlTimeConverterTest method testCalendar2Timestamp.
@Test
public void testCalendar2Timestamp() {
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(time);
Time sqltime = sqlTimeConverter.convert(calendar);
assertEquals(time, sqltime.getTime());
}
use of java.sql.Time in project jodd by oblac.
the class SqlTimeConverterTest method testSqlTime2Timestamp.
@Test
public void testSqlTime2Timestamp() {
Time sqltime2 = new Time(time);
Time sqltime = sqlTimeConverter.convert(sqltime2);
assertEquals(time, sqltime.getTime());
}
use of java.sql.Time in project presto by prestodb.
the class TestField method testTime.
@Test
public void testTime() throws Exception {
Type type = TIME;
Time expected = new Time(new GregorianCalendar(1999, 0, 1, 12, 30, 0).getTime().getTime());
Field f1 = new Field(expected, type);
assertEquals(f1.getTime(), expected);
assertEquals(f1.getObject(), expected);
assertEquals(f1.getType(), type);
assertEquals(f1.toString(), "TIME '12:30:00'");
Field f2 = new Field(f1);
assertEquals(f2, f1);
}
use of java.sql.Time in project presto by prestodb.
the class H2QueryRunner method rowMapper.
private static ResultSetMapper<MaterializedRow> rowMapper(final List<? extends Type> types) {
return new ResultSetMapper<MaterializedRow>() {
@Override
public MaterializedRow map(int index, ResultSet resultSet, StatementContext ctx) throws SQLException {
int count = resultSet.getMetaData().getColumnCount();
checkArgument(types.size() == count, "type does not match result");
List<Object> row = new ArrayList<>(count);
for (int i = 1; i <= count; i++) {
Type type = types.get(i - 1);
if (BOOLEAN.equals(type)) {
boolean booleanValue = resultSet.getBoolean(i);
if (resultSet.wasNull()) {
row.add(null);
} else {
row.add(booleanValue);
}
} else if (TINYINT.equals(type)) {
byte byteValue = resultSet.getByte(i);
if (resultSet.wasNull()) {
row.add(null);
} else {
row.add(byteValue);
}
} else if (SMALLINT.equals(type)) {
short shortValue = resultSet.getShort(i);
if (resultSet.wasNull()) {
row.add(null);
} else {
row.add(shortValue);
}
} else if (INTEGER.equals(type)) {
int intValue = resultSet.getInt(i);
if (resultSet.wasNull()) {
row.add(null);
} else {
row.add(intValue);
}
} else if (BIGINT.equals(type)) {
long longValue = resultSet.getLong(i);
if (resultSet.wasNull()) {
row.add(null);
} else {
row.add(longValue);
}
} else if (REAL.equals(type)) {
float floatValue = resultSet.getFloat(i);
if (resultSet.wasNull()) {
row.add(null);
} else {
row.add(floatValue);
}
} else if (DOUBLE.equals(type)) {
double doubleValue = resultSet.getDouble(i);
if (resultSet.wasNull()) {
row.add(null);
} else {
row.add(doubleValue);
}
} else if (isVarcharType(type)) {
String stringValue = resultSet.getString(i);
if (resultSet.wasNull()) {
row.add(null);
} else {
row.add(stringValue);
}
} else if (isCharType(type)) {
String stringValue = resultSet.getString(i);
if (resultSet.wasNull()) {
row.add(null);
} else {
row.add(padEnd(stringValue, ((CharType) type).getLength(), ' '));
}
} else if (DATE.equals(type)) {
Date dateValue = resultSet.getDate(i);
if (resultSet.wasNull()) {
row.add(null);
} else {
row.add(dateValue);
}
} else if (TIME.equals(type) || TIME_WITH_TIME_ZONE.equals(type)) {
Time timeValue = resultSet.getTime(i);
if (resultSet.wasNull()) {
row.add(null);
} else {
row.add(timeValue);
}
} else if (TIMESTAMP.equals(type) || TIMESTAMP_WITH_TIME_ZONE.equals(type)) {
Timestamp timestampValue = resultSet.getTimestamp(i);
if (resultSet.wasNull()) {
row.add(null);
} else {
row.add(timestampValue);
}
} else if (UNKNOWN.equals(type)) {
Object objectValue = resultSet.getObject(i);
checkState(resultSet.wasNull(), "Expected a null value, but got %s", objectValue);
row.add(null);
} else if (type instanceof DecimalType) {
BigDecimal decimalValue = resultSet.getBigDecimal(i);
if (resultSet.wasNull()) {
row.add(null);
} else {
row.add(decimalValue);
}
} else {
throw new AssertionError("unhandled type: " + type);
}
}
return new MaterializedRow(MaterializedResult.DEFAULT_PRECISION, row);
}
};
}
use of java.sql.Time in project querydsl by querydsl.
the class CaseForEqBuilderTest method timeType.
@Test
public void timeType() {
Customer c = alias(Customer.class, "customer");
TimeExpression<Time> cases = $(c.getAnnualSpending()).when(1000L).then(new Time(0)).otherwise(new Time(0));
assertNotNull(cases);
}
Aggregations