{"record":{"id":"4ab5c7b219ecf966","repo":"apache/shardingsphere","slug":"invalid-s-datetime-pattern-should-be-s-value","errorCode":null,"errorMessage":"Invalid %s, datetime pattern should be '%s', value is '%s'.","messagePattern":"Invalid (.+?), datetime pattern should be '(.+?)', value is '(.+?)'\\.","errorType":"exception","errorClass":"InvalidDatetimeFormatException","httpStatus":null,"severity":"error","filePath":"features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/AutoIntervalShardingAlgorithm.java","lineNumber":75,"sourceCode":"    private long shardingSeconds;\n    \n    @Getter\n    private int autoTablesAmount;\n    \n    @Override\n    public void init(final Properties props) {\n        dateTimeLower = getDateTime(props);\n        shardingSeconds = getShardingSeconds(props);\n        autoTablesAmount = (int) (Math.ceil((double) (parseDate(props.getProperty(DATE_TIME_UPPER_KEY)) / shardingSeconds)) + 2D);\n    }\n    \n    private LocalDateTime getDateTime(final Properties props) {\n        String value = props.getProperty(DATE_TIME_LOWER_KEY);\n        ShardingSpherePreconditions.checkNotNull(value, () -> new AlgorithmInitializationException(this, String.format(\"%s cannot be null.\", DATE_TIME_LOWER_KEY)));\n        try {\n            return LocalDateTime.parse(value, DateTimeFormatterFactory.getDatetimeFormatter());\n        } catch (final DateTimeParseException ignored) {\n            throw new InvalidDatetimeFormatException(DATE_TIME_LOWER_KEY, value, \"yyyy-MM-dd HH:mm:ss\");\n        }\n    }\n    \n    private long getShardingSeconds(final Properties props) {\n        ShardingSpherePreconditions.checkContainsKey(props, SHARDING_SECONDS_KEY, () -> new AlgorithmInitializationException(this, String.format(\"%s cannot be null.\", SHARDING_SECONDS_KEY)));\n        return Long.parseLong(props.getProperty(SHARDING_SECONDS_KEY));\n    }\n    \n    @Override\n    public String doSharding(final Collection<String> availableTargetNames, final PreciseShardingValue<Comparable<?>> shardingValue) {\n        ShardingSpherePreconditions.checkNotNull(shardingValue.getValue(), NullShardingValueException::new);\n        String tableNameSuffix = String.valueOf(doSharding(parseDate(shardingValue.getValue())));\n        return ShardingAutoTableAlgorithmUtils.findMatchedTargetName(availableTargetNames, tableNameSuffix, shardingValue.getDataNodeInfo()).orElse(null);\n    }\n    \n    @Override\n    public Collection<String> doSharding(final Collection<String> availableTargetNames, final RangeShardingValue<Comparable<?>> shardingValue) {\n        Collection<String> result = new LinkedHashSet<>(availableTargetNames.size(), 1F);","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/AutoIntervalShardingAlgorithm.java#L57-L93","documentation":"Thrown by AutoIntervalShardingAlgorithm when the datetime-lower property cannot be parsed with the fixed 'yyyy-MM-dd HH:mm:ss' formatter (DateTimeParseException is caught and converted). Auto-interval sharding needs a valid lower datetime anchor to compute time buckets, so initialization aborts.","triggerScenarios":"Setting sharding-algorithm props datetime-lower to a date-only value ('2020-01-01'), an ISO instant ('2020-01-01T00:00:00'), or any string not matching 'yyyy-MM-dd HH:mm:ss'.","commonSituations":"Copying values from IntervalShardingAlgorithm examples that allow custom patterns; omitting the time part; using a T separator; trailing spaces or quotes in YAML.","solutions":["Write the value exactly as 'yyyy-MM-dd HH:mm:ss', e.g. datetime-lower: '2020-01-01 00:00:00'","Remove quotes only if YAML still parses the space-containing scalar correctly (quoting is the safe choice)","Also check datetime-upper with the same format since it is parsed by the same parser","If you need a custom pattern, switch to INTERVAL sharding type which supports datetime-pattern"],"exampleFix":"# before\n- !SHARDING_ALGORITHM\n  type: AUTO_INTERVAL\n  props:\n    datetime-lower: 2020-01-01\n# after\n- !SHARDING_ALGORITHM\n  type: AUTO_INTERVAL\n  props:\n    datetime-lower: '2020-01-01 00:00:00'","handlingStrategy":"validation","validationCode":"try {\n    LocalDateTime.parse(props.getProperty(\"datetime-lower\"), DateTimeFormatter.ofPattern(\"yyyy-MM-dd HH:mm:ss\"));\n} catch (DateTimeParseException ex) {\n    throw new IllegalArgumentException(\"datetime-lower must be 'yyyy-MM-dd HH:mm:ss'\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Standardize datetime literals in config templates","Add a pre-deploy config validator that parses all datetime props"],"tags":["sharding","datetime","algorithm-init","config"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}