{"record":{"id":"0664f1508254a6b6","repo":"theonedev/onedev","slug":"invalid-date-range-expecting-yyyy-mm-dd-to-yyyy","errorCode":null,"errorMessage":"Invalid date range, expecting \"yyyy-MM-dd to yyyy-MM-dd\"","messagePattern":"Invalid date range, expecting \"yyyy-MM-dd to yyyy-MM-dd\"","errorType":"validation","errorClass":"ConversionException","httpStatus":null,"severity":"warning","filePath":"server-core/src/main/java/io/onedev/server/web/component/datepicker/DateRangePicker.java","lineNumber":47,"sourceCode":"    public DateRangePicker(String id, IModel<DateRange> model) {\n    \tsuper(id, model);\n\n\t\tsetType(DateRange.class);\n\t\tconverter = new IConverter<DateRange>() {\n\n\t\t\t@Override\n\t\t\tpublic DateRange convertToObject(String value, Locale locale) throws ConversionException {\n\t\t\t\tif (value == null) {\n\t\t\t\t\treturn null;\n\t\t\t\t} else {\n\t\t\t\t\tvar errorMessage = _T(\"Invalid date range, expecting \\\"yyyy-MM-dd to yyyy-MM-dd\\\"\");\n\t\t\t\t\tif (value.contains(\" \")) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tvar fromDate = LocalDate.from(DateUtils.DATE_FORMATTER.parse(StringUtils.substringBefore(value, \" \")));\n\t\t\t\t\t\t\tvar toDate = LocalDate.from(DateUtils.DATE_FORMATTER.parse(StringUtils.substringAfterLast(value, \" \")));\n\t\t\t\t\t\t\treturn new DateRange(fromDate, toDate);\n\t\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\t\tthrow new ConversionException(errorMessage);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tvar date = LocalDate.from(DateUtils.DATE_FORMATTER.parse(value));\n\t\t\t\t\t\t\treturn new DateRange(date, date);\n\t\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\t\tthrow new ConversionException(errorMessage);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic String convertToString(DateRange value, Locale locale) {\n\t\t\t\tif (value == null)\n\t\t\t\t\treturn null;\n\t\t\t\telse if (!value.getFrom().equals(value.getTo()))\n\t\t\t\t\treturn value.getFrom().format(DateUtils.DATE_FORMATTER) + \" to \" + value.getTo().format(DateUtils.DATE_FORMATTER);","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/web/component/datepicker/DateRangePicker.java#L29-L65","documentation":"DateRangePicker.convertToObject() parses a value containing a space as \"<fromDate> to <toDate>\" using DateUtils.DATE_FORMATTER (yyyy-MM-dd). If either date cannot be parsed, it throws a Wicket ConversionException with errorMessage \"Invalid date range, expecting \\\"yyyy-MM-dd to yyyy-MM-dd\\\"\". This is standard form-input validation feedback.","triggerScenarios":"Submitting a range like \"01/02/2024 to 03/02/2024\", \"2024-1-5 to 2024-1-9\" (non-padded), or any space-containing string whose first and last space-separated tokens are not valid yyyy-MM-dd dates.","commonSituations":"Users typing dates in locale formats (MM/dd/yyyy, dd.MM.yyyy); extra whitespace variants like \"2024-01-01  -  2024-01-05\" (substringBefore/afterLast handles multiple spaces only partially); pasted ranges with different separators.","solutions":["Enter the range exactly as \"yyyy-MM-dd to yyyy-MM-dd\", e.g. \"2024-01-01 to 2024-01-31\".","For a single day, submit just \"yyyy-MM-dd\" without a range.","If rendering the picker UI yourself, keep the date format hint consistent with DateUtils.DATE_FORMATTER and avoid free-text entry."],"exampleFix":"// before\npicker.setModelObject(\"01/01/2024 to 31/01/2024\");\n\n// after\npicker.setModelObject(\"2024-01-01 to 2024-01-31\");","handlingStrategy":"validation","validationCode":"static final DateTimeFormatter FMT = DateTimeFormatter.ofPattern(\"yyyy-MM-dd\");\nboolean valid = value != null && value.matches(\"\\\\d{4}-\\\\d{2}-\\\\d{2}( to \\\\d{4}-\\\\d{2}-\\\\d{2})?\");","typeGuard":"static boolean isDateRangeString(String s) {\n    return s != null && s.matches(\"\\\\d{4}-\\\\d{2}-\\\\d{2}( to \\\\d{4}-\\\\d{2}-\\\\d{2})?\");\n}","tryCatchPattern":"try {\n    DateRange range = (DateRange) picker.getConvertedInput();\n} catch (ConversionException e) {\n    feedback.error(\"Use format yyyy-MM-dd to yyyy-MM-dd\");\n}","preventionTips":["Always use the picker widget rather than typing dates free-form.","Use ISO yyyy-MM-dd in scripts and bookmarks.","Remember a single date (no range) is also accepted."],"tags":["date","validation","format","wicket"],"backgroundTag":"invalid-date-format","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}