Skip to content

Commit 1ef5fff

Browse files
authored
fix: [3721] IllegalArgumentException in date picker (#3859)
#3721
1 parent 329216c commit 1ef5fff

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

CodenameOne/src/com/codename1/ui/spinner/DateSpinner3D.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -403,13 +403,13 @@ public void setCurrentYear(int currentYear) {
403403
if (!explicitStartYear && startYear > currentYear) {
404404
startYear = currentYear;
405405
}
406-
if (!explicitEndYear && endYear -1 < currentYear) {
407-
endYear = currentYear+1;
406+
if (!explicitEndYear && endYear < currentYear) {
407+
endYear = currentYear;
408408
}
409409
if (currentYear < startYear) {
410410
throw new IllegalArgumentException("Current year "+currentYear+" before start year "+startYear);
411411
}
412-
if (currentYear > endYear - 1) {
412+
if (currentYear > endYear) {
413413
throw new IllegalArgumentException("Current year "+currentYear+" after end year "+endYear);
414414
}
415415
if(year != null) {
@@ -433,13 +433,13 @@ public void setCurrentDay(int currentDay) {
433433
if (!explicitStartDay && startDay > currentDay) {
434434
startDay = currentDay;
435435
}
436-
if (!explicitEndDay && endDay -1 < currentDay) {
437-
endDay = currentDay + 1;
436+
if (!explicitEndDay && endDay < currentDay) {
437+
endDay = currentDay;
438438
}
439439
if (startDay > currentDay) {
440440
throw new IllegalArgumentException("Start day "+startDay+" after current day "+currentDay);
441441
}
442-
if (endDay -1 < currentDay) {
442+
if (endDay < currentDay) {
443443
throw new IllegalArgumentException("End day "+endDay+" before current day "+currentDay);
444444
}
445445
if(day != null) {
@@ -466,13 +466,13 @@ public void setCurrentMonth(int currentMonth) {
466466
if (!explicitStartMonth && startMonth > currentMonth) {
467467
startMonth = currentMonth;
468468
}
469-
if (!explicitEndMonth && endMonth -1 < currentMonth) {
470-
endMonth = currentMonth+1;
469+
if (!explicitEndMonth && endMonth < currentMonth) {
470+
endMonth = currentMonth;
471471
}
472472
if (startMonth > currentMonth) {
473473
throw new IllegalArgumentException("Start month "+startMonth+" after current month "+currentMonth);
474474
}
475-
if (endMonth -1 < currentMonth) {
475+
if (endMonth < currentMonth) {
476476
throw new IllegalArgumentException("End month "+endMonth+" before current month "+currentMonth);
477477
}
478478
if(month != null) {

0 commit comments

Comments
 (0)