{"record":{"id":"543f9670bd896ca9","repo":"Bigkoo/Android-PickerView","slug":"the-enddate-should-not-be-later-than-2100","errorCode":null,"errorMessage":"The endDate should not be later than 2100","messagePattern":"The endDate should not be later than 2100","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pickerview/src/main/java/com/bigkoo/pickerview/view/TimePickerView.java","lineNumber":123,"sourceCode":"            setRange();\n        }\n\n        //若手动设置了时间范围限制\n        if (mPickerOptions.startDate != null && mPickerOptions.endDate != null) {\n            if (mPickerOptions.startDate.getTimeInMillis() > mPickerOptions.endDate.getTimeInMillis()) {\n                throw new IllegalArgumentException(\"startDate can't be later than endDate\");\n            } else {\n                setRangDate();\n            }\n        } else if (mPickerOptions.startDate != null) {\n            if (mPickerOptions.startDate.get(Calendar.YEAR) < 1900) {\n                throw new IllegalArgumentException(\"The startDate can not as early as 1900\");\n            } else {\n                setRangDate();\n            }\n        } else if (mPickerOptions.endDate != null) {\n            if (mPickerOptions.endDate.get(Calendar.YEAR) > 2100) {\n                throw new IllegalArgumentException(\"The endDate should not be later than 2100\");\n            } else {\n                setRangDate();\n            }\n        } else {//没有设置时间范围限制，则会使用默认范围。\n            setRangDate();\n        }\n\n        setTime();\n        wheelTime.setLabels(mPickerOptions.label_year, mPickerOptions.label_month, mPickerOptions.label_day\n                , mPickerOptions.label_hours, mPickerOptions.label_minutes, mPickerOptions.label_seconds);\n        wheelTime.setTextXOffset(mPickerOptions.x_offset_year, mPickerOptions.x_offset_month, mPickerOptions.x_offset_day,\n                mPickerOptions.x_offset_hours, mPickerOptions.x_offset_minutes, mPickerOptions.x_offset_seconds);\n        wheelTime.setItemsVisible(mPickerOptions.itemsVisibleCount);\n        wheelTime.setAlphaGradient(mPickerOptions.isAlphaGradient);\n        setOutSideCancelable(mPickerOptions.cancelable);\n        wheelTime.setCyclic(mPickerOptions.cyclic);\n        wheelTime.setDividerColor(mPickerOptions.dividerColor);\n        wheelTime.setDividerType(mPickerOptions.dividerType);","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/Bigkoo/Android-PickerView/blob/e200d8c063aa2568d728854c048340ad2e4e0c0b/pickerview/src/main/java/com/bigkoo/pickerview/view/TimePickerView.java#L105-L141","documentation":"TimePickerView.initWheelTime throws this IllegalArgumentException when only an endDate is configured and its year is later than 2100. The picker's date wheels are capped at year 2100, so a later end date cannot be represented.","triggerScenarios":"Calling setRangDate(null, endDate) or Builder .setEndDate() with a Calendar whose Calendar.YEAR > 2100, e.g. 'expiry date 100 years from now' computed from the current year, or a sentinel far-future date like 9999-12-31.","commonSituations":"Computing max dates via Calendar arithmetic (now + N years) without capping; using a 'never expires' sentinel date of year 9999; validation defaults that assume unlimited range.","solutions":["Cap the endDate at December 31, 2100 or earlier","Clamp computed future dates: if (end.get(Calendar.YEAR) > 2100) end.set(2100, Calendar.DECEMBER, 31)","Validate the configured end year before constructing TimePickerView"],"exampleFix":"// before\nCalendar end = Calendar.getInstance();\nend.add(Calendar.YEAR, 100); // e.g. 2126 -> throws\n// after\nif (end.get(Calendar.YEAR) > 2100) {\n    end.set(2100, Calendar.DECEMBER, 31);\n}","handlingStrategy":"validation","validationCode":"if (end != null && end.get(Calendar.YEAR) > 2100) end.set(2100, Calendar.DECEMBER, 31);","typeGuard":null,"tryCatchPattern":"try {\n    TimePickerView pv = new TimePickerView.Builder(ctx).setRangDate(null, end).build();\n} catch (IllegalArgumentException e) {\n    // cap end year at 2100 and rebuild\n}","preventionTips":["Clamp any computed far-future expiry dates to <= 2100-12-31","Avoid year-9999 'never expires' sentinels with this picker","Clamp relative offsets like now+N years"],"tags":["android","timepicker","date-range","invalid-argument-value"],"backgroundTag":"value-out-of-range","analyzedSha":"e200d8c063aa2568d728854c048340ad2e4e0c0b","analyzedAt":"2026-09-07T23:07:09.243Z","contentChangedAt":"2026-09-07T23:07:09.243Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}