Skip to content

Fix DateFormatTest DST mismatch: use calendar.getTime() instead of ne… - #7630

Draft
rishabh-ibm wants to merge 1 commit into
adoptium:masterfrom
rishabh-ibm:timezoneAPICHG
Draft

Fix DateFormatTest DST mismatch: use calendar.getTime() instead of ne…#7630
rishabh-ibm wants to merge 1 commit into
adoptium:masterfrom
rishabh-ibm:timezoneAPICHG

Conversation

@rishabh-ibm

Copy link
Copy Markdown
Contributor

DateFormatTest.parse() was calling tz.inDaylightTime(new Date()) to determine whether to fetch the DST or standard timezone display name. This uses the current wall-clock instant rather than the instant being formatted (calendar.getTime()).

When the default JVM timezone observes DST and the current wall-clock time is in a different DST state than the calendar's time, the timezone display name diverges from what DateFormat.format() produces, causing checkParse() to fail.

Fix: pass calendar.getTime() so the DST flag matches the instant the formatter is formatting, consistent with DateFormat behaviour.

Fixes MBCS_Tests_i18n_zh_TW_linux_0 DateFormatTest failure on JDK27.

…w Date()

DateFormatTest.parse() was calling tz.inDaylightTime(new Date()) to
determine whether to fetch the DST or standard timezone display name.
This uses the current wall-clock instant rather than the instant being
formatted (calendar.getTime()).

When the default JVM timezone observes DST and the current wall-clock
time is in a different DST state than the calendar's time, the timezone
display name diverges from what DateFormat.format() produces, causing
checkParse() to fail.

Fix: pass calendar.getTime() so the DST flag matches the instant the
formatter is formatting, consistent with DateFormat behaviour.

Fixes MBCS_Tests_i18n_zh_TW_linux_0 DateFormatTest failure on JDK27.

Signed-off-by: Rishabh Thakur <rishabh@ibm.com>
@JasonFengJ9

Copy link
Copy Markdown
Contributor

Grinder

07:25:20  TESTING:
07:25:20  1..3
07:25:20  # linux_zh_TW.UTF-8
07:25:20  base /home/jenkins/workspace/Grinder/jvmtest/functional/MBCS_Tests/i18n/
07:25:22  ok 1 - showlocale test
07:25:22  ok 2 - BreakIteratorTest test
07:25:22  not ok 3 - DateFormatTest
07:25:22  #   Failed test 'DateFormatTest'
07:25:22  #   at /home/jenkins/workspace/Grinder/aqa-tests/TKG/../../jvmtest/functional/MBCS_Tests/i18n/test.pl line 121.
07:25:22  # Looks like you failed 1 test of 3.
07:25:22  -----------------------------------
07:25:22  MBCS_Tests_i18n_zh_TW_linux_0_FAILED

buffer.append(tz.getDisplayName(tz.inDaylightTime(calendar.getTime()), TimeZone.LONG));
}else{
buffer.append(tz.getDisplayName(tz.inDaylightTime(new Date()), TimeZone.SHORT));
buffer.append(tz.getDisplayName(tz.inDaylightTime(calendar.getTime()), TimeZone.SHORT));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
buffer.append(tz.getDisplayName(tz.inDaylightTime(calendar.getTime()), TimeZone.SHORT));
int displayNameStyle = (followingCount >= 3) ? TimeZone.LONG : TimeZone.SHORT;
buffer.append(tz.getDisplayName(tz.inDaylightTime(calendar.getTime()), displayNameStyle));

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants