Fix DateFormatTest DST mismatch: use calendar.getTime() instead of ne… - #7630
Draft
rishabh-ibm wants to merge 1 commit into
Draft
Fix DateFormatTest DST mismatch: use calendar.getTime() instead of ne…#7630rishabh-ibm wants to merge 1 commit into
rishabh-ibm wants to merge 1 commit into
Conversation
…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>
Contributor
|
JasonFengJ9
reviewed
Aug 25, 2026
| 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)); |
Contributor
There was a problem hiding this comment.
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)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.