Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throwing IllegalArgumentException while formatting minimum date of Minguo calendar #792

Closed
iamcalendar opened this issue Jun 21, 2018 · 8 comments

Comments

@iamcalendar
Copy link

iamcalendar commented Jun 21, 2018

After running the following code

CalendarSystem<MinguoCalendar> calsys = MinguoCalendar.axis().getCalendarSystem();
MinguoCalendar minDate = calsys.transform(calsys.getMinimumSinceUTC()); // BEFORE_ROC-1000001911-01-01
ChronoFormatter<MinguoCalendar> formatter = ChronoFormatter
        .ofPattern("yyyy", PatternType.CLDR, Locale.ENGLISH, MinguoCalendar.axis());
System.out.println(formatter.format(minDate));

we get

IllegalArgumentException: Element YEAR_OF_ERA cannot be printed as the formatted value 1000001911 exceeds the maximum width of 9.

while expecting 1000001911 as output (because minDate is formattable).

We suggest to change the minimum date of Minguo calendar to BEFORE_ROC-999999999-01-01

In other word, we suggest to override getMinimumSinceUTC method of MinguoCalendar class as

@Override
public long getMinimumSinceUTC() {
    return -365242521549; // BEFORE_ROC-999999999-01-01
}
@MenoData
Copy link
Owner

Sounds reasonable (minimum effort for making such extreme values formattable which is more important than to support the edge case value itself).

@MenoData
Copy link
Owner

MenoData commented Jun 25, 2018

Similar problem also located in Julian calendar, Thai solar calendar etc. Let's favor formattability for such extrem values.

@MenoData
Copy link
Owner

I have now extended the general formattability of integer elements up to 10 digits (see issue #797). This solves your problem, too. Do you still insist on adjusting the value ranges of MinguoCalendar or ThaiSolarCalendar? Keep in mind that the actual ranges fit well with the range of PlainDate.

@iamcalendar
Copy link
Author

No need to adjust the range. Thanks!

@MenoData MenoData added the fixed label Jun 29, 2018
@MenoData
Copy link
Owner

MenoData commented Jun 29, 2018

Okay, then I can close this issue, too (indirectly fixed by issue #797). The next release of Time4A is not far away (maybe next week).

@iamcalendar
Copy link
Author

iamcalendar commented Oct 14, 2018

This is kindly FYI that the problem still exists in Time4A version 3.44.4-2018e.

@MenoData
Copy link
Owner

Will have a look soon...

@MenoData MenoData reopened this Oct 15, 2018
MenoData added a commit that referenced this issue Oct 16, 2018
MenoData added a commit that referenced this issue Oct 16, 2018
see issue #792
@MenoData MenoData added the bug label Oct 16, 2018
@MenoData
Copy link
Owner

Sorry for this oversight. But I have now also added your example as (successful) test case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants