{"record":{"id":"31d63caca8e3fde8","repo":"pentaho/pentaho-kettle","slug":"can-t-be-converted-to-a-timestamp","errorCode":null,"errorMessage":" : can't be converted to a timestamp","messagePattern":" : can't be converted to a timestamp","errorType":"exception","errorClass":"KettleValueException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/row/value/ValueMetaTimestamp.java","lineNumber":438,"sourceCode":"   * @throws KettleValueException in case there is a data conversion error\n   */\n  @Override\n  public Object convertData( ValueMetaInterface meta2, Object data2 ) throws KettleValueException {\n    switch ( meta2.getType() ) {\n      case TYPE_TIMESTAMP:\n        return ( (ValueMetaTimestamp) meta2 ).getTimestamp( data2 );\n      case TYPE_STRING:\n        return convertStringToTimestamp( meta2.getString( data2 ) );\n      case TYPE_INTEGER:\n        return convertIntegerToTimestamp( meta2.getInteger( data2 ) );\n      case TYPE_NUMBER:\n        return convertNumberToTimestamp( meta2.getNumber( data2 ) );\n      case TYPE_DATE:\n        return convertDateToTimestamp( meta2.getDate( data2 ) );\n      case TYPE_BIGNUMBER:\n        return convertBigNumberToTimestamp( meta2.getBigNumber( data2 ) );\n      default:\n        throw new KettleValueException( meta2.toStringMeta() + \" : can't be converted to a timestamp\" );\n    }\n  }\n\n  @Override\n  public Object cloneValueData( Object object ) throws KettleValueException {\n    Timestamp timestamp = getTimestamp( object );\n    if ( timestamp == null ) {\n      return null;\n    }\n\n    Timestamp clone = new Timestamp( timestamp.getTime() );\n    clone.setNanos( timestamp.getNanos() );\n    return clone;\n  }\n\n  @Override\n  public ValueMetaInterface getMetadataPreview( DatabaseMeta databaseMeta, ResultSet rs )\n    throws KettleDatabaseException {","sourceCodeStart":420,"sourceCodeEnd":456,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/row/value/ValueMetaTimestamp.java#L420-L456","documentation":"Thrown by ValueMetaTimestamp.convertData when the source value metadata has a storage type that has no defined conversion to Timestamp. Only Number, Date and BigNumber source types are supported; anything else hits the default branch and a KettleValueException is thrown.","triggerScenarios":"Calling convertData(meta2, data2) where meta2 is a ValueMeta of type String, Boolean, Integer, Binary or Serializable — e.g. converting a String field directly to Timestamp without going through Date.","commonSituations":"Row conversions in transform steps when field type metadata changed (e.g. field switched from Date to String upstream), mapping steps bridging streams with mismatched types.","solutions":["Convert String sources to Date first, then to Timestamp","Fix upstream field metadata so the source type is Date/Number/BigNumber","Insert a 'Value Mapper'/'Select Values' metadata change step between the streams"],"exampleFix":"// before\nTimestamp ts = (Timestamp) tsMeta.convertData(stringMeta, data);\n// after\nObject asDate = dateMeta.convertData(stringMeta, data);\nTimestamp ts = (Timestamp) tsMeta.convertData(dateMeta, asDate);","handlingStrategy":"type-guard","validationCode":"if (sourceMeta.getType() != ValueMetaInterface.TYPE_DATE\n && sourceMeta.getType() != ValueMetaInterface.TYPE_NUMBER\n && sourceMeta.getType() != ValueMetaInterface.TYPE_BIGNUMBER) {\n  throw new IllegalArgumentException(\"Cannot convert source type \" + sourceMeta.getTypeDesc() + \" to Timestamp\");\n}","typeGuard":"boolean canConvertToTimestamp(ValueMetaInterface src) {\n  int t = src.getType();\n  return t == ValueMetaInterface.TYPE_DATE || t == ValueMetaInterface.TYPE_NUMBER || t == ValueMetaInterface.TYPE_BIGNUMBER;\n}","tryCatchPattern":"try {\n  return tsMeta.convertData(srcMeta, data);\n} catch (KettleValueException e) {\n  return tsMeta.convertData(dateMeta, srcMeta.getType() == ValueMetaInterface.TYPE_STRING ? srcMeta.convertToNormalStorageTypes(data) : data);\n}","preventionTips":["Check the source value meta type before any convertData call","Route string-to-timestamp conversions through Date explicitly","Keep field type metadata consistent across transforms in a pipeline"],"tags":["pdi","timestamp","type-conversion","value-meta"],"backgroundTag":"incompatible-source-type","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}