{"record":{"id":"4834b94c62127d49","repo":"pentaho/pentaho-kettle","slug":"i-don-t-know-how-to-convert-a-boolean-to-a-timestamp","errorCode":null,"errorMessage":" : I don't know how to convert a boolean to a timestamp.","messagePattern":" : I don't know how to convert a boolean 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":186,"sourceCode":"            return convertIntegerToTimestamp( (Long) convertBinaryStringToNativeType( (byte[]) object ) );\n          case STORAGE_TYPE_INDEXED:\n            return convertIntegerToTimestamp( (Long) index[ ( (Integer) object ).intValue() ] );\n          default:\n            throw new KettleValueException( toString() + \" : Unknown storage type \" + storageType + \" specified.\" );\n        }\n      case TYPE_BIGNUMBER:\n        switch ( storageType ) {\n          case STORAGE_TYPE_NORMAL:\n            return convertBigNumberToTimestamp( (BigDecimal) object );\n          case STORAGE_TYPE_BINARY_STRING:\n            return convertBigNumberToTimestamp( (BigDecimal) convertBinaryStringToNativeType( (byte[]) object ) );\n          case STORAGE_TYPE_INDEXED:\n            return convertBigNumberToTimestamp( (BigDecimal) index[ ( (Integer) object ).intValue() ] );\n          default:\n            throw new KettleValueException( toString() + \" : Unknown storage type \" + storageType + \" specified.\" );\n        }\n      case TYPE_BOOLEAN:\n        throw new KettleValueException( toString() + \" : I don't know how to convert a boolean to a timestamp.\" );\n      case TYPE_BINARY:\n        throw new KettleValueException( toString() + \" : I don't know how to convert a binary value to timestamp.\" );\n      case TYPE_SERIALIZABLE:\n        throw new KettleValueException( toString()\n          + \" : I don't know how to convert a serializable value to timestamp.\" );\n\n      default:\n        throw new KettleValueException( toString() + \" : Unknown type \" + type + \" specified.\" );\n    }\n  }\n\n  public int compare( Object data1, Object data2 ) throws KettleValueException {\n    Timestamp timestamp1 = getTimestamp( data1 );\n    Timestamp timestamp2 = getTimestamp( data2 );\n    int cmp = 0;\n    if ( timestamp1 == null ) {\n      if ( timestamp2 == null ) {\n        cmp = 0;","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/row/value/ValueMetaTimestamp.java#L168-L204","documentation":"ValueMetaTimestamp.getTimestamp() refuses to convert Boolean source values: the TYPE_BOOLEAN case unconditionally throws this KettleValueException because PDI defines no boolean-to-timestamp mapping. The message is prefixed with the field's toString() so you can see which field was involved.","triggerScenarios":"getTimestamp(object) invoked on a ValueMetaTimestamp whose internal type is TYPE_BOOLEAN, i.e. the value metadata claims the source data is a Boolean, regardless of storage type.","commonSituations":"A stream field previously Boolean was re-declared as Timestamp while data is still boolean; generic row-copying code that calls getTimestamp for every field without checking the declared type; merge/join steps mixing metadata from two sources with conflicting types.","solutions":["Align the metadata with the actual data: if the value is Boolean, keep the field type TYPE_BOOLEAN, or convert the source to a Timestamp-compatible type (String/Date) first with a 'Value Mapper' or 'Calculator' step.","In code, branch on valueMeta.getType() and only call getTimestamp() for convertible types (String, Number, Integer, BigNumber, Date); handle Boolean explicitly with your own rule.","If you own the data, change the upstream step so it emits a real timestamp (e.g. TODATE() or a Calculator conversion) instead of a boolean.","As a last resort, subclass or wrap the ValueMeta and override getTimestamp() to define a custom boolean->timestamp mapping, though explicit pre-conversion is preferred."],"exampleFix":"// before\nTimestamp t = meta.getTimestamp( booleanObject ); // always throws\n// after\nif ( meta.getType() == ValueMetaInterface.TYPE_BOOLEAN ) {\n  Boolean b = meta.getBoolean( booleanObject );\n  Timestamp t = b != null && b ? new Timestamp( 0L ) : null; // explicit rule\n} else {\n  Timestamp t = meta.getTimestamp( booleanObject );\n}","handlingStrategy":"type-guard","validationCode":"if ( meta.getType() == ValueMetaInterface.TYPE_BOOLEAN ) {\n  // do not call getTimestamp(); convert the boolean explicitly first\n}","typeGuard":"boolean isTimestampConvertible( ValueMetaInterface meta ) {\n  switch ( meta.getType() ) {\n    case ValueMetaInterface.TYPE_TIMESTAMP:\n    case ValueMetaInterface.TYPE_DATE:\n    case ValueMetaInterface.TYPE_STRING:\n    case ValueMetaInterface.TYPE_NUMBER:\n    case ValueMetaInterface.TYPE_INTEGER:\n    case ValueMetaInterface.TYPE_BIGNUMBER:\n      return true;\n    default:\n      return false; // BOOLEAN, BINARY, SERIALIZABLE are not convertible\n  }\n}","tryCatchPattern":"try {\n  t = meta.getTimestamp( value );\n} catch ( KettleValueException e ) {\n  if ( e.getMessage().contains( \"convert a boolean to a timestamp\" ) ) {\n    Boolean b = meta.getBoolean( value );\n    t = ( b != null && b ) ? new Timestamp( 0L ) : null; // explicit mapping\n  } else { throw e; }\n}","preventionTips":["Check meta.getType() before calling getTimestamp().","Convert boolean fields to String/Date upstream with a Calculator or Value Mapper step.","Keep stream field types consistent between producing and consuming steps.","Define your boolean->timestamp rule explicitly instead of relying on the library."],"tags":["kettle","pdi","type-conversion","timestamp","boolean"],"backgroundTag":"type-mismatch","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"}