{"record":{"id":"9d7c72f456f79ddf","repo":"jwtk/jjwt","slug":"string-value-is-not-a-jwt-numericdate-nor-is-it-i","errorCode":null,"errorMessage":"String value is not a JWT NumericDate, nor is it ISO-8601-formatted. All heuristics exhausted. Cause: ${e.getMessage()}","messagePattern":"String value is not a JWT NumericDate, nor is it ISO-8601-formatted\\. All heuristics exhausted\\. Cause: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"impl/src/main/java/io/jsonwebtoken/impl/lang/JwtDateConverter.java","lineNumber":108,"sourceCode":"            String msg = \"Cannot create Date from object of type \" + v.getClass().getName() + \".\";\n            throw new IllegalArgumentException(msg);\n        }\n    }\n\n    /**\n     * Parses the specified ISO-8601-formatted string and returns the corresponding {@link Date} instance.\n     *\n     * @param value an ISO-8601-formatted string.\n     * @return a {@link Date} instance reflecting the specified ISO-8601-formatted string.\n     * @since 0.10.0\n     */\n    private static Date parseIso8601Date(String value) throws IllegalArgumentException {\n        try {\n            return DateFormats.parseIso8601Date(value);\n        } catch (ParseException e) {\n            String msg = \"String value is not a JWT NumericDate, nor is it ISO-8601-formatted. \" +\n                    \"All heuristics exhausted. Cause: \" + e.getMessage();\n            throw new IllegalArgumentException(msg, e);\n        }\n    }\n}\n","sourceCodeStart":90,"sourceCodeEnd":112,"githubUrl":"https://github.com/jwtk/jjwt/blob/fb71496164c71442d08adec4571d9616ed5e1b8d/impl/src/main/java/io/jsonwebtoken/impl/lang/JwtDateConverter.java#L90-L112","documentation":"Thrown by JwtDateConverter.parseIso8601Date when a string claim value (e.g. 'exp', 'iat', 'nbf') cannot be parsed as a JWT NumericDate nor as an ISO-8601 date, after all parsing heuristics failed. The underlying ParseException message is appended as the cause. It surfaces as an IllegalArgumentException while converting date claims during JWT construction or parsing.","triggerScenarios":"Setting a date claim to a non-numeric, non-ISO-8601 string such as header.put(\"exp\", \"tomorrow\") or passing arbitrary text into a converter expecting a date representation.","commonSituations":"Hand-built JWTs where date claims are supplied as raw strings instead of Date/Instant objects; copying claim values from another token with wrong formatting; locale-specific date strings like '12/31/2026'.","solutions":["Pass java.util.Date, java.time.Instant or a numeric seconds-since-epoch value instead of a string for date claims.","If a string is required, format it as ISO-8601, e.g. '2026-09-08T12:00:00Z'.","Catch IllegalArgumentException and log the cause message to identify the malformed value."],"exampleFix":"// before\njwtBuilder.claim(\"exp\", \"tomorrow afternoon\");\n// after\njwtBuilder.expiration(new Date(System.currentTimeMillis() + 3600_000L));","handlingStrategy":"validation","validationCode":"boolean validDateClaim(Object v) {\n    if (v instanceof Number || v instanceof java.util.Date || v instanceof java.time.Instant) return true;\n    if (v instanceof String s) {\n        try { Long.parseLong(s); return true; } catch (NumberFormatException ignored) {}\n        try { java.time.OffsetDateTime.parse(s); return true; } catch (Exception ignored) {}\n    }\n    return false;\n}","typeGuard":null,"tryCatchPattern":"try {\n    jwtBuilder.claim(\"exp\", rawValue);\n} catch (IllegalArgumentException e) {\n    // message starts with \"String value is not a JWT NumericDate...\"\n    throw new IllegalArgumentException(\"Invalid date claim value: \" + rawValue, e);\n}","preventionTips":["Always pass Date/Instant objects for date claims instead of strings","Use JwtBuilder's typed expiration()/issuedAt()/notBefore() methods","Never copy raw string date claims between tokens without revalidating"],"tags":["jwt","date-parsing","illegal-argument"],"backgroundTag":"invalid-date-format","analyzedSha":"fb71496164c71442d08adec4571d9616ed5e1b8d","analyzedAt":"2026-09-09T00:33:09.982Z","contentChangedAt":"2026-09-09T00:33:09.982Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}