{"record":{"id":"e01f6b88c9a3fa96","repo":"quarkusio/quarkus","slug":"not-a-formattable-date-time-object","errorCode":null,"errorMessage":"Not a formattable date/time object: ","messagePattern":"Not a formattable date/time object: ","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/qute/runtime/src/main/java/io/quarkus/qute/runtime/extensions/TimeTemplateExtensions.java","lineNumber":75,"sourceCode":"        return format(getFormattableObject(dateTimeObject, timeZone), pattern, locale, timeZone);\n    }\n\n    private static TemporalAccessor getFormattableObject(Object value,\n            ZoneId timeZone) {\n        if (value instanceof TemporalAccessor) {\n            return (TemporalAccessor) value;\n        } else if (value instanceof Date) {\n            return LocalDateTime.ofInstant(((Date) value).toInstant(),\n                    timeZone);\n        } else if (value instanceof Calendar) {\n            return LocalDateTime.ofInstant(((Calendar) value).toInstant(),\n                    timeZone);\n        } else if (value instanceof Number) {\n            return LocalDateTime.ofInstant(\n                    Instant.ofEpochMilli(((Number) value).longValue()),\n                    timeZone);\n        } else {\n            throw new IllegalArgumentException(\"Not a formattable date/time object: \" + value);\n        }\n    }\n\n    private static DateTimeFormatter formatterForKey(Key key) {\n        DateTimeFormatter formatter;\n        DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder();\n        builder.appendPattern(key.pattern);\n        if (key.locale != null) {\n            formatter = builder.toFormatter(key.locale);\n        } else {\n            formatter = builder.toFormatter();\n        }\n        return key.timeZone != null ? formatter.withZone(key.timeZone) : formatter;\n    }\n\n    static final class Key {\n\n        private final String pattern;","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/qute/runtime/src/main/java/io/quarkus/qute/runtime/extensions/TimeTemplateExtensions.java#L57-L93","documentation":"The Qute time template extensions (formatDate/formatTime/formatDateTime via {#format} or time namespace) convert the given value before formatting. If the value is neither a temporal type (TemporalAccessor) nor a Number epoch-milli, the extension throws this IllegalArgumentException because it cannot render the object as a date/time.","triggerScenarios":"Calling {#format myValue format=\"...\"} (or time.format) with a value that is a String, Instant-like unsupported wrapper, null object, or arbitrary POJO instead of a date/time type or epoch millis Number.","commonSituations":"Passing a String date (e.g. \"2024-01-01\") from config/JSON without parsing it first; passing a wrong model property due to a name typo (resolves to a different bean); passing java.util.Date-like values that were converted or a Long representing seconds (not millis).","solutions":["Pass a supported type: TemporalAccessor (LocalDate/LocalDateTime/ZonedDateTime/Instant...) or a Number of epoch milliseconds.","Parse String dates before rendering, or expose a getter returning a temporal type on the data model.","Check for property-name typos so the correct date field is resolved.","Note epoch values must be in milliseconds — convert seconds with Instant.ofEpochSecond(...) in your model."],"exampleFix":"// before\ndata.put(\"created\", \"2024-01-01\");\n// after\ndata.put(\"created\", LocalDate.of(2024, 1, 1)); // or Instant.ofEpochMilli(ms)","handlingStrategy":"type-guard","validationCode":"if (!(value instanceof TemporalAccessor) && !(value instanceof Number)) {\n    throw new IllegalArgumentException(\"Value not formattable as date/time: \" + value);\n}","typeGuard":"boolean isFormattable(Object v) {\n    return v instanceof TemporalAccessor || v instanceof Number;\n}","tryCatchPattern":"try { engine.render(tpl, data); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"Not a formattable date/time object\")) { /* fix model value type */ } else throw e; }","preventionTips":["Expose temporal types (LocalDate/Instant/...) in data models","Parse String dates before rendering","Ensure epoch values are milliseconds, not seconds","Verify template property names resolve to the intended field"],"tags":["qute","templates","datetime","type-mismatch"],"backgroundTag":"unsupported-datetime-type","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}