theonedev/onedev · warning · ConversionException
Invalid date range, expecting "yyyy-MM-dd to yyyy-MM-dd"
Error message
Invalid date range, expecting "yyyy-MM-dd to yyyy-MM-dd"
What it means
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.
Source
Thrown at server-core/src/main/java/io/onedev/server/web/component/datepicker/DateRangePicker.java:47
public DateRangePicker(String id, IModel<DateRange> model) {
super(id, model);
setType(DateRange.class);
converter = new IConverter<DateRange>() {
@Override
public DateRange convertToObject(String value, Locale locale) throws ConversionException {
if (value == null) {
return null;
} else {
var errorMessage = _T("Invalid date range, expecting \"yyyy-MM-dd to yyyy-MM-dd\"");
if (value.contains(" ")) {
try {
var fromDate = LocalDate.from(DateUtils.DATE_FORMATTER.parse(StringUtils.substringBefore(value, " ")));
var toDate = LocalDate.from(DateUtils.DATE_FORMATTER.parse(StringUtils.substringAfterLast(value, " ")));
return new DateRange(fromDate, toDate);
} catch (Exception e) {
throw new ConversionException(errorMessage);
}
} else {
try {
var date = LocalDate.from(DateUtils.DATE_FORMATTER.parse(value));
return new DateRange(date, date);
} catch (Exception e) {
throw new ConversionException(errorMessage);
}
}
}
}
@Override
public String convertToString(DateRange value, Locale locale) {
if (value == null)
return null;
else if (!value.getFrom().equals(value.getTo()))
return value.getFrom().format(DateUtils.DATE_FORMATTER) + " to " + value.getTo().format(DateUtils.DATE_FORMATTER);View on GitHub (pinned to d44925c47c)
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.
Example fix
// before
picker.setModelObject("01/01/2024 to 31/01/2024");
// after
picker.setModelObject("2024-01-01 to 2024-01-31"); Defensive patterns
Strategy: validation
Validate before calling
static final DateTimeFormatter FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd");
boolean valid = value != null && value.matches("\\d{4}-\\d{2}-\\d{2}( to \\d{4}-\\d{2}-\\d{2})?"); Type guard
static boolean isDateRangeString(String s) {
return s != null && s.matches("\\d{4}-\\d{2}-\\d{2}( to \\d{4}-\\d{2}-\\d{2})?");
} Try / catch
try {
DateRange range = (DateRange) picker.getConvertedInput();
} catch (ConversionException e) {
feedback.error("Use format yyyy-MM-dd to yyyy-MM-dd");
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Unrecognized date: ${value}
- Null or empty component ID's are not allowed.
- The component ID must not contain ':' or '~' chars.
- Title is required
- Count should not be greater than ${RestConstants.MAX_PAGE_SI
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/0664f1508254a6b6.
Report an issue: GitHub.