{"record":{"id":"b0e262a6e8bbfcc4","repo":"Bigkoo/Android-PickerView","slug":"the-startdate-can-not-as-early-as-1900","errorCode":null,"errorMessage":"The startDate can not as early as 1900","messagePattern":"The startDate can not as early as 1900","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pickerview/src/main/java/com/bigkoo/pickerview/view/TimePickerView.java","lineNumber":117,"sourceCode":"        }\n\n        wheelTime.setLunarMode(mPickerOptions.isLunarCalendar);\n\n        if (mPickerOptions.startYear != 0 && mPickerOptions.endYear != 0\n                && mPickerOptions.startYear <= mPickerOptions.endYear) {\n            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);","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/Bigkoo/Android-PickerView/blob/e200d8c063aa2568d728854c048340ad2e4e0c0b/pickerview/src/main/java/com/bigkoo/pickerview/view/TimePickerView.java#L99-L135","documentation":"TimePickerView.initWheelTime throws this IllegalArgumentException when only a startDate is configured and its year is earlier than 1900. The underlying wheel/date tables only support years from 1900, so an earlier start date cannot be represented.","triggerScenarios":"Calling setRangDate(startDate, null) or Builder .setStartDate() with a Calendar whose Calendar.YEAR < 1900 (e.g. an epoch-based Calendar of 0ms, or a 'birth date' field defaulting to year 1900 minus something).","commonSituations":"Passing new Calendar.Builder().setDate(0,0,1) or Calendar.getInstance() zeroed to epoch (1970 is fine, but year-0 defaults are not); using a minimum-date placeholder like 1899; misreading the supported range.","solutions":["Raise the startDate to January 1, 1900 or later","If older dates are needed, this library cannot support them — pick another date library","Validate the configured start year before constructing TimePickerView"],"exampleFix":"// before\nCalendar start = Calendar.getInstance();\nstart.set(1899, Calendar.JANUARY, 1); // throws\n// after\nstart.set(1900, Calendar.JANUARY, 1); // minimum supported","handlingStrategy":"validation","validationCode":"if (start != null && start.get(Calendar.YEAR) < 1900) start.set(1900, Calendar.JANUARY, 1);","typeGuard":null,"tryCatchPattern":"try {\n    TimePickerView pv = new TimePickerView.Builder(ctx).setRangDate(start, null).build();\n} catch (IllegalArgumentException e) {\n    // clamp start year and rebuild\n}","preventionTips":["Never use sentinel/epoch-zero Calendars as minimum dates","Clamp start year to >= 1900","Remember this library cannot represent pre-1900 dates at all"],"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"}