{"record":{"id":"e21c669762b7c1d2","repo":"pentaho/pentaho-kettle","slug":"i-don-t-know-how-to-convert-a-boolean-to-a-date","errorCode":null,"errorMessage":" : I don't know how to convert a boolean to a date.","messagePattern":" : I don't know how to convert a boolean to a date\\.","errorType":"exception","errorClass":"KettleValueException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java","lineNumber":2361,"sourceCode":"            return convertIntegerToDate( (Long) convertBinaryStringToNativeType( (byte[]) object ) );\n          case STORAGE_TYPE_INDEXED:\n            return convertIntegerToDate( (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 convertBigNumberToDate( (BigDecimal) object );\n          case STORAGE_TYPE_BINARY_STRING:\n            return convertBigNumberToDate( (BigDecimal) convertBinaryStringToNativeType( (byte[]) object ) );\n          case STORAGE_TYPE_INDEXED:\n            return convertBigNumberToDate( (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 date.\" );\n      case TYPE_BINARY:\n        throw new KettleValueException( toString() + \" : I don't know how to convert a binary value to date.\" );\n      case TYPE_SERIALIZABLE:\n        throw new KettleValueException( toString() + \" : I don't know how to convert a serializable value to date.\" );\n\n      default:\n        throw new KettleValueException( toString() + \" : Unknown type \" + type + \" specified.\" );\n    }\n  }\n\n  @Override\n  public byte[] getBinary( Object object ) throws KettleValueException {\n    if ( object == null ) {\n      return null;\n    }\n    switch ( type ) {\n      case TYPE_BINARY:\n        switch ( storageType ) {","sourceCodeStart":2343,"sourceCodeEnd":2379,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java#L2343-L2379","documentation":"ValueMetaBase.getDate(Object) throws this KettleValueException when the field's type is TYPE_BOOLEAN. PDI defines no boolean-to-date conversion — there is no meaningful mapping from true/false to a Date — so it fails fast instead of inventing one. The message is prefixed with the field's toString() (name and type metadata).","triggerScenarios":"Calling getDate(object) (directly or via RowMeta.getDate/row getters) on a field declared as Boolean, e.g. new ValueMetaBoolean(...) or a Boolean column feeding a Date-typed target in the transformation.","commonSituations":"Mapping mistakes where a Boolean flag column is wired to a Date output field; metadata edits that changed a Date field to Boolean while downstream steps still request dates; custom step code reading fields without checking getType().","solutions":["Correct the field mapping so a Date-typed (or String/Number/Integer/BigNumber) field feeds the getDate call.","Change the field's value type to TYPE_DATE (or a convertible type) with an explicit conversion if a boolean really must become a date.","Catch KettleValueException and handle the Boolean field explicitly (e.g. map true/false to fixed dates in your own code)."],"exampleFix":"// before\nDate d = valueMeta.getDate( row[i] ); // valueMeta is TYPE_BOOLEAN -> throws\n// after\nif ( valueMeta.getType() == ValueMetaInterface.TYPE_BOOLEAN ) {\n  Date d = Boolean.TRUE.equals( valueMeta.getBoolean( row[i] ) ) ? activeDate : inactiveDate;\n} else {\n  Date d = valueMeta.getDate( row[i] );\n}","handlingStrategy":"type-guard","validationCode":"if ( valueMeta.getType() == ValueMetaInterface.TYPE_BOOLEAN ) {\n  throw new IllegalArgumentException( \"Field \" + valueMeta.getName() + \" is BOOLEAN; cannot read as Date\" );\n}","typeGuard":"boolean readableAsDate( ValueMetaInterface vm ) {\n  int t = vm.getType();\n  return t == ValueMetaInterface.TYPE_DATE || t == ValueMetaInterface.TYPE_STRING\n      || t == ValueMetaInterface.TYPE_INTEGER || t == ValueMetaInterface.TYPE_NUMBER\n      || t == ValueMetaInterface.TYPE_BIGNUMBER;\n}","tryCatchPattern":"try {\n  Date d = valueMeta.getDate( row[i] );\n} catch ( KettleValueException e ) {\n  logError( \"Cannot read \" + valueMeta.getName() + \" as date: \" + e.getMessage() );\n  // map the boolean to a date explicitly or skip the field\n}","preventionTips":["Check valueMeta.getType() before calling getDate.","Wire Date-compatible fields (Date/String/Number/Integer/BigNumber) into Date targets.","Use a Select values / calculator step for explicit boolean-to-date mapping if truly needed."],"tags":["kettle","value-conversion","date","boolean","type-mismatch"],"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"}