protected Timestamp convertNumberToTimestamp( Double d ) { if ( d == null ) { return null; } long nanos = d.longValue(); return convertIntegerToTimestamp( nanos ); }
protected Timestamp convertBigNumberToTimestamp( BigDecimal bd ) { if ( bd == null ) { return null; } return convertIntegerToTimestamp( bd.longValue() ); }
switch ( storageType ) { case STORAGE_TYPE_NORMAL: return convertIntegerToTimestamp( (Long) object ); case STORAGE_TYPE_BINARY_STRING: return convertIntegerToTimestamp( (Long) convertBinaryStringToNativeType( (byte[]) object ) ); case STORAGE_TYPE_INDEXED: return convertIntegerToTimestamp( (Long) index[( (Integer) object ).intValue()] ); default: throw new KettleValueException( toString() + " : Unknown storage type " + storageType + " specified." );
/** * Convert the specified data to the data type specified in this object. * * @param meta2 * the metadata of the object to be converted * @param data2 * the data of the object to be converted * @return the object in the data type of this value metadata object * @throws KettleValueException * in case there is a data conversion error */ @Override public Object convertData( ValueMetaInterface meta2, Object data2 ) throws KettleValueException { switch ( meta2.getType() ) { case TYPE_TIMESTAMP: return ( (ValueMetaTimestamp) meta2 ).getTimestamp( data2 ); case TYPE_STRING: return convertStringToTimestamp( meta2.getString( data2 ) ); case TYPE_INTEGER: return convertIntegerToTimestamp( meta2.getInteger( data2 ) ); case TYPE_NUMBER: return convertNumberToTimestamp( meta2.getNumber( data2 ) ); case TYPE_DATE: return convertDateToTimestamp( meta2.getDate( data2 ) ); case TYPE_BIGNUMBER: return convertBigNumberToTimestamp( meta2.getBigNumber( data2 ) ); default: throw new KettleValueException( meta2.toStringMeta() + " : can't be converted to a timestamp" ); } }