{"record":{"id":"9f3b174a5edc22ff","repo":"apache/incubator-seata","slug":"the-time-format-does-not-match-yyyy-mm-dd-hh-mm-ss","errorCode":null,"errorMessage":"The time format does not match yyyy-MM-dd HH:mm:ss","messagePattern":"The time format does not match yyyy-MM-dd HH:mm:ss","errorType":"validation","errorClass":"DateTimeException","httpStatus":null,"severity":"error","filePath":"console/src/main/java/org/apache/seata/mcp/core/utils/DateUtils.java","lineNumber":55,"sourceCode":"    }\n\n    public static long convertToTimestampFromDate(String dateStr) {\n        if (!isValidDate(dateStr)) {\n            throw new DateTimeException(\"The time format does not match yyyy-MM-dd\");\n        }\n        LocalDate date = LocalDate.parse(dateStr);\n        ZonedDateTime zonedDateTime = date.atStartOfDay(ZoneId.systemDefault());\n        return zonedDateTime.toInstant().toEpochMilli();\n    }\n\n    public static long convertToTimeStampFromDateTime(String dateTimeStr) {\n        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(\"yyyy-MM-dd HH:mm:ss\");\n\n        try {\n            LocalDateTime dateTime = LocalDateTime.parse(dateTimeStr, formatter);\n            return dateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();\n        } catch (DateTimeParseException e) {\n            throw new DateTimeException(\"The time format does not match yyyy-MM-dd HH:mm:ss\", e);\n        }\n    }\n\n    public static String convertToDateTimeFromTimestamp(Long timestamp) {\n        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(\"yyyy-MM-dd HH:mm:ss\");\n        LocalDateTime dateTime;\n        try {\n            dateTime = Instant.ofEpochMilli(timestamp)\n                    .atZone(ZoneId.systemDefault())\n                    .toLocalDateTime();\n        } catch (DateTimeException | ArithmeticException e) {\n            return \"Parse Failed, please check that the timestamp is correct\";\n        }\n        return dateTime.format(formatter);\n    }\n\n    public static boolean judgeExceedTimeDuration(Long startTime, Long endTime, Long maxDuration) {\n        if (endTime < startTime) throw new IllegalArgumentException(\"endTime must not be earlier than startTime\");","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/apache/incubator-seata/blob/e01f97c6db397165050caa6764020410c2c8199a/console/src/main/java/org/apache/seata/mcp/core/utils/DateUtils.java#L37-L73","documentation":"DateUtils.convertToTimeStampFromDateTime throws DateTimeException (wrapping DateTimeParseException) when the input cannot be parsed with the pattern 'yyyy-MM-dd HH:mm:ss'. The console MCP tools use it for time-range query parameters; the fixed 24-hour pattern means timezone offsets, 'T' separators, fractional seconds, or 12-hour clock values all fail.","triggerScenarios":"Calling convertToTimeStampFromDateTime with values like '2026-08-14T10:00:00', '2026-08-14 10:00' (missing seconds), '2026-08-14 22:30:00.123', or '2026-08-14 2pm'.","commonSituations":"ISO-8601 formatted timestamps from MCP clients (the 'T' separator is the most common culprit), second-precision omission, or passing a plain date where a full datetime is required.","solutions":["Format the parameter exactly as 'yyyy-MM-dd HH:mm:ss' with 24-hour clock, e.g. '2026-08-14 09:30:00'","Convert ISO strings client-side before invoking the tool: replace 'T' with a space and drop millis/offset","For date-only input use convertToTimestampFromDate instead","Validate with a try-parse of DateTimeFormatter.ofPattern(\"yyyy-MM-dd HH:mm:ss\") before calling"],"exampleFix":"// before\nLong ts = DateUtils.convertToTimeStampFromDateTime(\"2026-08-14T09:30:00\"); // throws\n\n// after\nLong ts = DateUtils.convertToTimeStampFromDateTime(\"2026-08-14 09:30:00\"); // ok","handlingStrategy":"validation","validationCode":"private static final DateTimeFormatter F = DateTimeFormatter.ofPattern(\"yyyy-MM-dd HH:mm:ss\");\ntry { LocalDateTime.parse(s, F); } catch (DateTimeParseException e) { throw new IllegalArgumentException(\"expected yyyy-MM-dd HH:mm:ss\"); }","typeGuard":"boolean isStrictDateTime(String s) { try { LocalDateTime.parse(s, DateTimeFormatter.ofPattern(\"yyyy-MM-dd HH:mm:ss\")); return true; } catch (DateTimeParseException e) { return false; } }","tryCatchPattern":"try { ts = DateUtils.convertToTimeStampFromDateTime(s); } catch (DateTimeException e) { return toolError(\"Invalid datetime '\" + s + \"', expected yyyy-MM-dd HH:mm:ss\"); }","preventionTips":["Normalize ISO-8601 input client-side: replace 'T' with space, strip millis/offset","Always include seconds at 24-hour clock","Pre-parse with the same formatter before invoking the tool"],"tags":["seata","mcp","date-parsing","console"],"backgroundTag":null,"analyzedSha":"e01f97c6db397165050caa6764020410c2c8199a","analyzedAt":"2026-08-14T10:23:53.097Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}