{"record":{"id":"0c13026bbd3048a5","repo":"pentaho/pentaho-kettle","slug":"i-don-t-know-how-to-convert-a-binary-value-to-date","errorCode":null,"errorMessage":" : I don't know how to convert a binary value to date.","messagePattern":" : I don't know how to convert a binary value to date\\.","errorType":"exception","errorClass":"KettleValueException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java","lineNumber":2363,"sourceCode":"            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 ) {\n          case STORAGE_TYPE_NORMAL:\n            return (byte[]) object;","sourceCodeStart":2345,"sourceCodeEnd":2381,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java#L2345-L2381","documentation":"ValueMetaBase.getDate(Object) throws this KettleValueException when the field's type is TYPE_BINARY. PDI has no rule for interpreting a raw byte[] as a Date (no implicit parsing/decoding), so it throws instead of returning garbage. The message includes the field's toString() so the offending field can be identified.","triggerScenarios":"Calling getDate(object) on a field declared TYPE_BINARY (e.g. new ValueMetaBinary(...), image/file content columns, or database BLOBs mapped as Binary) — especially when such a column is wired to a Date-typed target or read with row.getDate(index).","commonSituations":"Binary/BLOB columns accidentally mapped to Date output fields; metadata edits changing a Date field to Binary while downstream steps still call getDate; custom step code that doesn't check getType() before reading.","solutions":["Fix the field mapping so a Date/String/Number/Integer/BigNumber field feeds the getDate call.","Change the field's value type to TYPE_DATE (or TYPE_STRING with a conversion mask) and provide the bytes in a parsable form.","Catch KettleValueException and decode/parse the binary content yourself (e.g. new String(bytes) then ConvertStringToDate)."],"exampleFix":"// before\nDate d = binaryMeta.getDate( row[i] ); // TYPE_BINARY -> throws\n// after\nstringMeta.setValueType( ValueMetaInterface.TYPE_STRING ); // hold e.g. \"2024-01-15\" text\nDate d = stringMeta.getDate( new String( (byte[]) row[i] ) );","handlingStrategy":"type-guard","validationCode":"if ( valueMeta.getType() == ValueMetaInterface.TYPE_BINARY ) {\n  throw new IllegalArgumentException( \"Field \" + valueMeta.getName() + \" is BINARY; 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( \"Binary field \" + valueMeta.getName() + \" cannot be read as date\" );\n  // decode bytes and parse manually if appropriate\n}","preventionTips":["Check getType() before typed getters.","Keep BLOB/Binary columns out of Date-typed mappings; convert explicitly first.","Define date fields as TYPE_DATE (or TYPE_STRING with a conversion mask) at the source."],"tags":["kettle","value-conversion","date","binary","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"}