Skip to content

fix: apply JSONReader context to SimpleDateFormat values - #7820

Open
DarrenChangJR wants to merge 1 commit into
alibaba:mainfrom
DarrenChangJR:fix/simple-date-format-context
Open

fix: apply JSONReader context to SimpleDateFormat values#7820
DarrenChangJR wants to merge 1 commit into
alibaba:mainfrom
DarrenChangJR:fix/simple-date-format-context

Conversation

@DarrenChangJR

Copy link
Copy Markdown

What this PR does and why

The SimpleDateFormat value reader currently invokes
SimpleDateFormat::new. It therefore ignores an explicitly configured
JSONReader.Context locale and zone, reconstructing the formatter with JVM
defaults instead.

This change replaces that generic constructor adapter with a small dedicated
reader. It keeps the existing string wire representation, uses the context
locale when one is configured, and applies the context zone after construction.

Reproducer

With Locale.FRANCE and GMT+08 set on the reader context, deserializing
"MMM" as SimpleDateFormat now produces a formatter whose time-zone ID is
GMT+08:00 and which formats epoch zero as janv.. Previously it produced
Jan in the JVM time zone.

Tests

  • text character input;
  • UTF-8 byte input;
  • JSONB input;
  • existing DateFormatTest and AutoTypeFilterTest2 coverage;
  • mvn -pl core -DskipTests validate;
  • clean full core suite: 7,977 tests, no failures or errors.

Checklist

  • Text and JSONB paths retain the existing pattern-string wire form.
  • Locale and zone both differ from JVM defaults in the regression.
  • Existing JSONB auto-type coverage passes.
  • Compatibility facade changes are kept in a separate PR.
中文说明

修改内容和原因

当前 SimpleDateFormat value reader 通过 SimpleDateFormat::new 构造对象,
因此即使调用方在 JSONReader.Context 中明确配置 locale 和时区,重建后的
formatter 仍使用 JVM 默认值。

本修改使用一个小型、无状态的专用 reader,保持原有 pattern 字符串 wire form,
在 locale 存在时用它构造 formatter,并设置 context 时区。

测试

回归测试覆盖字符 JSON、UTF-8 JSON 和 JSONB;已有日期与 JSONB auto-type 测试、
Maven validate,以及 clean 后完整 7,977 个 core 测试均通过。

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.

1 participant