{"record":{"id":"3689896aaf0445b8","repo":"pentaho/pentaho-kettle","slug":"the-default-value-defaultvalue-should-be-of-format","errorCode":null,"errorMessage":"The default value \" + defaultValue + \" should be of format : \" + ValueMetaBase.DEFAULT_DATE_PARSE_MASK","messagePattern":"The default value \" \\+ defaultValue \\+ \" should be of format : \" \\+ ValueMetaBase\\.DEFAULT_DATE_PARSE_MASK","errorType":"exception","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"plugins/avro-format/core/src/main/java/org/pentaho/di/trans/steps/avro/output/PentahoAvroOutputFormat.java","lineNumber":319,"sourceCode":"   * @see org.pentaho.di.trans.steps.avro.AvroToPdiConverter #convertToPentahoType(int, String, IAvroInputField)\n   * </P>\n   *\n   * <p>\n   * @param defaultValue The default value provided.\n   * @return The integer value of converted default value to Date.\n   */\n  private int getDateTypeForDefaultValue( String defaultValue ) throws ParseException {\n    Date defaultDate;\n    DateFormat dateFormat = new SimpleDateFormat( ValueMetaBase.DEFAULT_DATE_PARSE_MASK );\n\n    try {\n      defaultDate = dateFormat.parse( defaultValue );\n      LocalDate localDate = defaultDate.toInstant()\n              .atZone( ZoneId.systemDefault() )\n              .toLocalDate();\n      return (int) localDate.toEpochDay();\n    } catch ( ParseException pe ) {\n      throw new ParseException( \"The default value \" + defaultValue + \" should be of format : \" + ValueMetaBase.DEFAULT_DATE_PARSE_MASK, pe.getErrorOffset() );\n    }\n\n  }\n\n  /**\n   * Converts the default value to TimeStamp(in Milliseconds).\n   *\n   * <P>\n   *  ValueMetaBase.DEFAULT_TIMESTAMP_PARSE_MASK is the default timestamp parser used for\n   *  Avro To PDI and vice-versa conversions.\n   * @see PentahoAvroRecordWriter#createAvroRecord\n   * </P>\n   *\n   * <p>\n   * @param defaultValue The default value provided.\n   * @return The long value of converted default value to Date and Time.\n   */\n  private long getTimeStampTypeForDefaultValue( String defaultValue ) throws ParseException {","sourceCodeStart":301,"sourceCodeEnd":337,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/avro-format/core/src/main/java/org/pentaho/di/trans/steps/avro/output/PentahoAvroOutputFormat.java#L301-L337","documentation":"ParseException re-thrown by PentahoAvroOutputFormat.getDateTypeForDefaultValue when the default value string cannot be parsed using ValueMetaBase.DEFAULT_DATE_PARSE_MASK (yyyy/MM/dd HH:mm:ss). The method converts a date string to epoch days for DATE-typed Avro fields.","triggerScenarios":"mapDefaultValuesToDataTypes dispatches a DATE field to getDateTypeForDefaultValue and dateFormat.parse(defaultValue) fails — the string is not in the expected date parse mask, or is empty/garbage.","commonSituations":"Entering a date like '12/31/2024' or '2024-12-31' when the mask expects 'yyyy/MM/dd HH:mm:ss'; leaving the default blank; regional date-order assumptions (dd/MM vs MM/dd); hand-editing transformation XML with an unparseable default.","solutions":["Set the default value to a string matching ValueMetaBase.DEFAULT_DATE_PARSE_MASK (e.g. '2024/12/31 00:00:00')","Normalize user-supplied dates with a permissive parser first, then format into the expected mask","Check for trailing whitespace or locale characters in the stored default value","Remove the default if the field does not need one","Note the inner exception's error offset to find exactly where the string stopped parsing"],"exampleFix":"// before\nfield.setDefault( \"2024-12-31\" );\n// after\nfield.setDefault( \"2024/12/31 00:00:00\" ); // matches DEFAULT_DATE_PARSE_MASK","handlingStrategy":"validation","validationCode":"String MASK = org.pentaho.di.compatibility.ValueMetaBase.DEFAULT_DATE_PARSE_MASK;\nnew java.text.SimpleDateFormat( MASK ).parse( defaultValue ); // throws ParseException if not in mask","typeGuard":"boolean isValidDateDefault( String v ) { try { new java.text.SimpleDateFormat( \"yyyy/MM/dd HH:mm:ss\" ).parse( v ); return true; } catch ( ParseException e ) { return false; } }","tryCatchPattern":"try { int epochDay = getDateTypeForDefaultValue( defaultValue ); }\ncatch ( ParseException pe ) { throw new IllegalArgumentException( \"Use format yyyy/MM/dd HH:mm:ss for date defaults: \" + defaultValue ); }","preventionTips":["Always enter date defaults as yyyy/MM/dd HH:mm:ss, including the 00:00:00 time part","Avoid ISO-8601 style ('2024-12-31' or with 'T'/'Z') in default fields","Trim whitespace from values before saving the step config","Document the required mask in your transformation templates"],"tags":["avro","date-format","parsing","default-value"],"backgroundTag":"invalid-date-format","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"}