@Test public void testConvertStringToTimestamp() throws Exception { ValueMetaTimestamp valueMetaTimestamp = new ValueMetaTimestamp(); assertEquals( Timestamp.valueOf( "2012-04-05 04:03:02.123456" ), valueMetaTimestamp .convertStringToTimestamp( "2012/4/5 04:03:02.123456" ) ); assertEquals( Timestamp.valueOf( "2012-04-05 04:03:02.123" ), valueMetaTimestamp .convertStringToTimestamp( "2012/4/5 04:03:02.123" ) ); assertEquals( Timestamp.valueOf( "2012-04-05 04:03:02.123456789" ), valueMetaTimestamp .convertStringToTimestamp( "2012/4/5 04:03:02.123456789" ) ); }
protected synchronized Timestamp convertStringToTimestamp( String string ) throws KettleValueException { string = Const.trimToType( string, getTrimType() ); if ( Utils.isEmpty( string ) ) { return null; } Timestamp returnValue; try { returnValue = Timestamp.valueOf( string ); } catch ( IllegalArgumentException e ) { try { returnValue = (Timestamp) getDateFormat().parse( string ); } catch ( ParseException ex ) { throw new KettleValueException( toString() + " : couldn't convert string [" + string + "] to a timestamp, expecting format [yyyy-mm-dd hh:mm:ss.ffffff]", e ); } } return returnValue; }
ValueMetaTimestamp extends ValueMetaDate { protected synchronized Timestamp convertStringToTimestamp( String string ) throws KettleValueException { string = Const.trimToType( string, getTrimType() ); if ( Utils.isEmpty( string ) ) { return null; } Timestamp returnValue; try { returnValue = Timestamp.valueOf( string ); } catch ( IllegalArgumentException e ) { try { returnValue = (Timestamp) getDateFormat().parse( string ); } catch ( ParseException ex ) { throw new KettleValueException( toString() + " : couldn't convert string [" + string + "] to a timestamp, expecting format [yyyy-mm-dd hh:mm:ss.ffffff]", e ); } } return returnValue; } }
ValueMetaTimestamp extends ValueMetaDate { protected synchronized Timestamp convertStringToTimestamp( String string ) throws KettleValueException { string = Const.trimToType( string, getTrimType() ); if ( Utils.isEmpty( string ) ) { return null; } Timestamp returnValue; try { returnValue = Timestamp.valueOf( string ); } catch ( IllegalArgumentException e ) { try { returnValue = (Timestamp) getDateFormat().parse( string ); } catch ( ParseException ex ) { throw new KettleValueException( toString() + " : couldn't convert string [" + string + "] to a timestamp, expecting format [yyyy-mm-dd hh:mm:ss.ffffff]", e ); } } return returnValue; } ValueMetaTimestamp();  ValueMetaTimestamp( String name ); }
ValueMetaTimestamp extends ValueMetaDate { protected synchronized Timestamp convertStringToTimestamp( String string ) throws KettleValueException { string = Const.trimToType( string, getTrimType() ); if ( Utils.isEmpty( string ) ) { return null; } Timestamp returnValue; try { returnValue = Timestamp.valueOf( string ); } catch ( IllegalArgumentException e ) { try { returnValue = (Timestamp) getDateFormat().parse( string ); } catch ( ParseException ex ) { throw new KettleValueException( toString() + " : couldn't convert string [" + string + "] to a timestamp, expecting format [yyyy-mm-dd hh:mm:ss.ffffff]", e ); } } return returnValue; } ValueMetaTimestamp();  ValueMetaTimestamp( String name ); @Override boolean isDate(); @Override Date getDate( Object object ); @Override Long getInteger( Object object ); @Override Double getNumber( Object object ); @Override BigDecimal getBigNumber( Object object ); @Override Boolean getBoolean( Object object ); @Override String getString( Object object ); Timestamp getTimestamp( Object object ); int compare( Object data1, Object data2 ); @Override Object convertDataFromString( String pol, ValueMetaInterface convertMeta, String nullIf, String ifNull,
      int trim_type ); Timestamp convertDateToTimestamp( Date date ); @Override Object convertData( ValueMetaInterface meta2, Object data2 ); @Override Object cloneValueData( Object object ); @Override ValueMetaInterface getValueFromSQLType( DatabaseMeta databaseMeta, String name, ResultSetMetaData rm,
      int index, boolean ignoreLength, boolean lazyConversion ); @Override Object getValueFromResultSet( DatabaseInterface databaseInterface, ResultSet resultSet, int index ); @Override void setPreparedStatementValue( DatabaseMeta databaseMeta, PreparedStatement preparedStatement, int index,
      Object data ); @Override Object convertDataUsingConversionMetaData( Object data2 ); @Override byte[] getBinaryString( Object object ); @Override void writeData( DataOutputStream outputStream, Object object ); @Override Object readData( DataInputStream inputStream ); @Override synchronized SimpleDateFormat getDateFormat(); @Override String getFormatMask(); @Override Class<?> getNativeDataTypeClass(); }
ValueMetaTimestamp extends ValueMetaDate { protected synchronized Timestamp convertStringToTimestamp( String string ) throws KettleValueException { string = Const.trimToType( string, getTrimType() ); if ( Utils.isEmpty( string ) ) { return null; } Timestamp returnValue; try { returnValue = Timestamp.valueOf( string ); } catch ( IllegalArgumentException e ) { try { returnValue = (Timestamp) getDateFormat().parse( string ); } catch ( ParseException ex ) { throw new KettleValueException( toString() + " : couldn't convert string [" + string + "] to a timestamp, expecting format [yyyy-mm-dd hh:mm:ss.ffffff]", e ); } } return returnValue; } ValueMetaTimestamp();  ValueMetaTimestamp( String name ); @Override boolean isDate(); @Override Date getDate( Object object ); @Override Long getInteger( Object object ); @Override Double getNumber( Object object ); @Override BigDecimal getBigNumber( Object object ); @Override Boolean getBoolean( Object object ); @Override String getString( Object object ); Timestamp getTimestamp( Object object ); int compare( Object data1, Object data2 ); @Override Object convertDataFromString( String pol, ValueMetaInterface convertMeta, String nullIf, String ifNull,
      int trim_type ); Timestamp convertDateToTimestamp( Date date ); @Override Object convertData( ValueMetaInterface meta2, Object data2 ); @Override Object cloneValueData( Object object ); @Override ValueMetaInterface getValueFromSQLType( DatabaseMeta databaseMeta, String name, ResultSetMetaData rm,
      int index, boolean ignoreLength, boolean lazyConversion ); @Override Object getValueFromResultSet( DatabaseInterface databaseInterface, ResultSet resultSet, int index ); @Override void setPreparedStatementValue( DatabaseMeta databaseMeta, PreparedStatement preparedStatement, int index,
      Object data ); @Override Object convertDataUsingConversionMetaData( Object data2 ); @Override byte[] getBinaryString( Object object ); @Override void writeData( DataOutputStream outputStream, Object object ); @Override Object readData( DataInputStream inputStream ); @Override synchronized SimpleDateFormat getDateFormat(); @Override String getFormatMask(); @Override Class<?> getNativeDataTypeClass();  }