APISonar


java.sql.Types.TIME

> java > sql > Types > TIME
java APIs sql APIs Types APIs TIME APIs

Example 1
public void testSetParameterValueWithSqlTime() throws SQLException {
		java.sql.Time time = new java.sql.Time(1000);
		StatementCreatorUtils.setParameterValue(preparedStatement, 1, Types.TIME, null, time);
		verify(preparedStatement).setTime(1, time);
	}
Example 2
public void setTime(int parameterIndex, Time x)
            throws SQLException
    {
        checkOpen();
        if (x == null) {
            setNull(parameterIndex, Types.TIME);
        }
        else {
            setParameter(parameterIndex, formatLiteral("TIME", TIME_FORMATTER.print(x.getTime())));
        }
    }
Example 3
public void testSetLocalTimeWithType() throws SQLException {
    LocalTime data = LocalTime.parse("16:21:51");
    Time actual = insertThenReadWithType(data, Types.TIME, "time_without_time_zone_column", Time.class);
    Time expected = Time.valueOf("16:21:51");
    assertEquals(expected, actual);
  }
Example 4
public Time getTime(int i, java.util.Calendar cal) throws SQLException {
    checkClosed();
    checkIndex(i, Types.TIME, "Time");

    if (callResult[i - 1] == null) {
      return null;
    }

    String value = callResult[i - 1].toString();
    return connection.getTimestampUtils().toTime(cal, value);
  }
Example 5
@Test public void testTime() {
    SqlTypeName tn =
        SqlTypeName.getNameForJdbcType(Types.TIME);
    assertEquals(
        "TIME did not map to TIME",
        SqlTypeName.TIME,
        tn);
  }
Example 6
public void bind(DataBind b, LocalTime value) throws SQLException {
    if (value == null) {
      b.setNull(Types.TIME);
    } else {
      b.setTime(new Time(value.toDateTimeToday().getMillis()));
    }
  }
Example 7
public void setValue(java.sql.Time field) throws SQLException {
        if (field != null) {
            _ps.setTime(_ind, field);
        } else {
            _ps.setNull(_ind, Types.TIME);
        }
        _ind++;
    }
Example 8
public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException {
        setParameter(parameterIndex, createParameter(Types.TIME, x, cal));

        createChain().preparedStatement_setTime(this, parameterIndex, x, cal);
    }
Example 9
public TimeColumn(String label, int nullable) throws SQLException {
        super(label, Types.TIME, nullable);
        this.setClassName(Time.class.getCanonicalName());
    }
Example 10
public void assertGetValueByTime() throws SQLException {
        ResultSet resultSet = getMockedResultSet(Types.TIME);
        when(resultSet.getTime(1)).thenReturn(new Time(0L));
        MemoryQueryResult actual = new MemoryQueryResult(resultSet);
        assertTrue(actual.next());
        assertThat(actual.getValue(1, Time.class), is((Object) new Time(0L)));
        assertFalse(actual.next());
    }
Example 11
public void testSetParameterValueWithTimeAndCalendar() throws SQLException {
		java.util.Calendar cal = new GregorianCalendar();
		StatementCreatorUtils.setParameterValue(preparedStatement, 1, Types.TIME, null, cal);
		verify(preparedStatement).setTime(1, new java.sql.Time(cal.getTime().getTime()), cal);
	}
Example 12
public static boolean isDate(int dataType) {
        List<Integer> validTypes = Arrays.asList(
                Types.DATE,
                Types.TIME,
                Types.TIMESTAMP
        );

        return validTypes.contains(dataType);
    }
Example 13
public void testSetParameterValueWithTimeAndUtilDate() throws SQLException {
		java.util.Date date = new java.util.Date(1000);
		StatementCreatorUtils.setParameterValue(preparedStatement, 1, Types.TIME, null, date);
		verify(preparedStatement).setTime(1, new java.sql.Time(1000));
	}
Example 14
public void readOfDateFieldWithTimeColumnWritesDate() throws Exception {
    FieldType fieldType = FieldType.DATE;
    when(metaData.getColumnType(1)).thenReturn(Types.TIME);
    java.sql.Time sqlTime = java.sql.Time.valueOf("22:33:44");
    Date expectedValue = new Date(sqlTime.getTime());
    when(resultSet.getTime(1)).thenReturn(sqlTime);
    sqlToPdxInstance.addMapping(COLUMN_NAME_1, PDX_FIELD_NAME_1, fieldType);

    PdxInstance result = createPdxInstance();

    verifyResult(expectedValue, result);
  }
Example 15
private static Map<Class<?>, Integer> types() {
        final Map<Class<?>, Integer> types = new HashMap<>();
        types.put(LocalDate.class, Types.DATE);
        types.put(LocalTime.class, Types.TIME);
        types.put(LocalDateTime.class, Types.TIMESTAMP);
        types.put(OffsetDateTime.class, Types.TIMESTAMP_WITH_TIMEZONE);
        return types;
    }
Example 16
public void testVerticaTimeType() throws Exception {
    // PDI-12244
    ResultSetMetaData metaData = mock( ResultSetMetaData.class );
    ValueMetaInterface valueMetaInterface = mock( ValueMetaInternetAddress.class );

    when( resultSet.getMetaData() ).thenReturn( metaData );
    when( metaData.getColumnType( 1 ) ).thenReturn( Types.TIME );
    when( resultSet.getTime( 1 ) ).thenReturn( new Time( 0 ) );
    when( valueMetaInterface.getOriginalColumnType() ).thenReturn( Types.TIME );
    when( valueMetaInterface.getType() ).thenReturn( ValueMetaInterface.TYPE_DATE );

    DatabaseInterface databaseInterface = new Vertica5DatabaseMeta();
    Object ret = databaseInterface.getValueFromResultSet( resultSet, valueMetaInterface, 0 );
    assertEquals( new Time( 0 ), ret );
  }
Example 17
private Object getNetezzaDateValueWorkaround( DatabaseInterface databaseInterface, ResultSet resultSet, int index )
    throws SQLException, KettleDatabaseException {
    Object data = null;
    int type = resultSet.getMetaData().getColumnType( index );
    switch ( type ) {
      case Types.TIME: {
        data = resultSet.getTime( index );
        break;
      }
      default: {
        data = resultSet.getDate( index );
      }
    }
    return data;
  }
Example 18
public void set(PreparedStatement prep, int parameterIndex) throws SQLException {
        try {
            prep.setObject(parameterIndex, JSR310Utils.valueToLocalTime(this, null), Types.TIME);
            return;
        } catch (SQLException ignore) {
            // Nothing to do
        }
        prep.setTime(parameterIndex, getTime(null, null));
    }
Example 19
public static Object coerceToSQLType(int jdbcType, Object value) {
        if (value.getClass() == java.util.Date.class) {
            if (jdbcType == Types.DATE) {
                return new java.sql.Date(((java.util.Date) value).getTime());
            } else if (jdbcType == Types.TIME) {
                return new java.sql.Time(((java.util.Date) value).getTime());
            } else if (jdbcType == Types.TIMESTAMP) {
                return new java.sql.Timestamp(((java.util.Date) value).getTime());
            }
        } else if (value.getClass() == Character.class && jdbcType == Types.VARCHAR) {
            value = value.toString();
        }
        return value;
    }
Example 20
public Object convertDatabaseValueToObject(Object defaultValue, int dataType, int columnSize, int decimalDigits, Database database) throws ParseException {
        if (defaultValue != null) {
            if (defaultValue instanceof String) {
                defaultValue = ((String) defaultValue).replaceAll("'::[\\w\\s]+$", "'");

                if (dataType == Types.DATE || dataType == Types.TIME || dataType == Types.TIMESTAMP) {
                    //remove trailing time zone info
                    defaultValue = ((String) defaultValue).replaceFirst("-\\d+$", "");
                }
            }
        }
        return super.convertDatabaseValueToObject(defaultValue, dataType, columnSize, decimalDigits, database);

    }
Example 21
public void testMetdataPreviewSqlTimeToPentahoDate() throws SQLException, KettleDatabaseException {
    doReturn( Types.TIME ).when( resultSet ).getInt( "DATA_TYPE" );
    ValueMetaInterface valueMeta = valueMetaBase.getMetadataPreview( dbMeta, resultSet );
    assertTrue( valueMeta.isDate() );
  }
Example 22
public String serialize(String literal, int jdbcType) {
        switch (jdbcType) {
            case Types.TIMESTAMP:
            case TIMESTAMP_WITH_TIMEZONE:
                return "{ts '" + literal + "'}";
            case Types.DATE:
                return "{d '" + literal + "'}";
            case Types.TIME:
            case TIME_WITH_TIMEZONE:
                return "{t '" + literal + "'}";
            default:
                return super.serialize(literal, jdbcType);
        }
    }
Example 23
protected DateTimeFormatter getNativeValueFormat(DBSTypedObject type) {
        switch (type.getTypeID()) {
            case Types.TIMESTAMP:
                return DEFAULT_TIMESTAMP_FORMAT;
            case Types.TIMESTAMP_WITH_TIMEZONE:
                return DEFAULT_TIMESTAMP_TZ_FORMAT;
            case Types.TIME:
                return DEFAULT_TIME_FORMAT;
            case Types.TIME_WITH_TIMEZONE:
                return DEFAULT_TIME_TZ_FORMAT;
            case Types.DATE:
                return DEFAULT_DATE_FORMAT;
        }
        return null;
    }
Example 24
public DBSplitter getSplitter(int sqlDataType, long splitLimit, String rangeStyle) {
    switch (sqlDataType) {
    case Types.DATE:
    case Types.TIME:
    case Types.TIMESTAMP:
      return new OracleDateSplitter();

    default:
      return super.getSplitter(sqlDataType, splitLimit, rangeStyle);
    }
  }
Example 25
public Object getValueFromObject(DBCSession session, DBSTypedObject type, Object object, boolean copy) throws DBCException {
        Object value = super.getValueFromObject(session, type, object, copy);
        if (value instanceof Date) {
            switch (type.getTypeID()) {
                case Types.TIME:
                case Types.TIME_WITH_TIMEZONE:
                    return getTimeValue(value);
                case Types.DATE:
                    return getDateValue(value);
                default:
                    return getTimestampValue(value);
            }
        }
        return value;
    }