You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fesod.apache.org by "Mikkey-f (via GitHub)" <gi...@apache.org> on 2026/08/28 13:21:43 UTC
[PR] fix: fall back to global 1904 windowing when @DateTimeFormat default is used (#1042) [fesod]
Mikkey-f opened a new pull request, #1054:
URL: https://github.com/apache/fesod/pull/1054
> **Summary**
>
> Fixes #1042. When a field carries `@DateTimeFormat` for the pattern only, its `use1904windowing` is left at `BooleanEnum.DEFAULT`; `DateTimeFormatProperty.build()` collapsed that to `false`, so the global 1904 windowing setting (builder option or workbook flag) was silently bypassed and date-number cells were interpreted with the 1900 windowing system, shifting dates by 1462 days (4 years).
>
> **Changes**
>
> - `DateTimeFormatProperty.build()`: preserve `DEFAULT` as `null` instead of collapsing it to `false`
> - New shared helper `DateUtils.resolveUse1904windowing(contentProperty, globalConfiguration)`: explicit annotation value wins, otherwise fall back to the global configuration (null-safe, defaults to `false`)
> - `DateNumberConverter`, `LocalDateNumberConverter`, `LocalDateTimeNumberConverter`, `LocalTimeNumberConverter`, `StringNumberConverter`: use the shared helper on both read and write paths
> - `TimestampNumberConverter` test fixture and the custom-converter example in `core-class.md` (EN/zh-CN) updated to the new helper, since they previously unboxed the property value directly
>
> **Testing**
>
> - New unit tests: `DateTimeFormatPropertyTest` (DEFAULT/TRUE/FALSE preserved), per-converter regression tests covering annotation-default + global 1904 → follows global; explicit annotation → annotation wins
> - New end-to-end regression test `DateTimeFormatDefaultWindowingTest` replicating the issue's reproduction steps: on the pre-fix code it fails with `expected: <2026-08-28T10:30> but was: <2022-08-27T10:30>` (the exact 4-year shift from the issue); on the fixed code it passes
> - Full suite: 913/913 green, spotless and javadoc pass
>
> **Note**
>
> Verified empirically that the write path already followed the global setting before this change (the write API consumes the annotation's `use1904windowing` only via the shared converters). The write-path test is kept as an invariant guard rather than a bug regression test. `OffsetDateTime`/`ZonedDateTime` converters on #1033 already implement the same fallback pattern and are unaffected.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fesod.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fesod.apache.org
For additional commands, e-mail: commits-help@fesod.apache.org
Re: [PR] fix: fall back to global 1904 windowing when @DateTimeFormat default is used (#1042) [fesod]
Posted by "bengbengbalabalabeng (via GitHub)" <gi...@apache.org>.
bengbengbalabalabeng commented on code in PR #1054:
URL: https://github.com/apache/fesod/pull/1054#discussion_r3922886472
##########
fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/DateTimeFormatProperty.java:
##########
@@ -52,8 +51,9 @@ public static DateTimeFormatProperty build(DateTimeFormat dateTimeFormat) {
if (dateTimeFormat == null) {
return null;
}
+ // Keep DEFAULT as null so converters can fall back to the global configuration
+ // instead of collapsing it to false (see #1042).
return new DateTimeFormatProperty(
- dateTimeFormat.value(),
- BooleanUtils.isTrue(dateTimeFormat.use1904windowing().getBooleanValue()));
+ dateTimeFormat.value(), dateTimeFormat.use1904windowing().getBooleanValue());
}
}
Review Comment:
Could we also add a Javadoc on the `use1904windowing` field explaining the behavior? Specifically, noting that `null` represents the `DEFAULT` state which indicates falling back to `GlobalConfiguration`, whereas `TRUE/FALSE` represents an explicit override.
This will prevent future maintainers from inadvertently collapsing `null` into `false` again.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fesod.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fesod.apache.org
For additional commands, e-mail: commits-help@fesod.apache.org
Re: [PR] fix: fall back to global 1904 windowing when @DateTimeFormat default is used (#1042) [fesod]
Posted by "Mikkey-f (via GitHub)" <gi...@apache.org>.
Mikkey-f commented on code in PR #1054:
URL: https://github.com/apache/fesod/pull/1054#discussion_r3924314628
##########
fesod-sheet/src/main/java/org/apache/fesod/sheet/util/DateUtils.java:
##########
@@ -373,6 +375,27 @@ public static String format(BigDecimal date, Boolean use1904windowing, String da
return format(localDateTime, dateFormat);
}
+ /**
+ * Resolve the 1904 windowing flag for a field: the annotation value wins when explicitly set, otherwise fall back
+ * to the global configuration (null-safe, defaults to false).
+ *
+ * @param contentProperty the field's content property, may be null
+ * @param globalConfiguration the global configuration
+ * @return true if dates use the 1904 windowing system
+ */
+ public static boolean resolveUse1904windowing(
Review Comment:
Thanks for the suggestion — I've renamed it to `isDate1904` in cb67fb1. The Javadoc now states the resolution order explicitly (annotation override first, then fall back to the global configuration).
##########
fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/DateTimeFormatProperty.java:
##########
@@ -52,8 +51,9 @@ public static DateTimeFormatProperty build(DateTimeFormat dateTimeFormat) {
if (dateTimeFormat == null) {
return null;
}
+ // Keep DEFAULT as null so converters can fall back to the global configuration
+ // instead of collapsing it to false (see #1042).
return new DateTimeFormatProperty(
- dateTimeFormat.value(),
- BooleanUtils.isTrue(dateTimeFormat.use1904windowing().getBooleanValue()));
+ dateTimeFormat.value(), dateTimeFormat.use1904windowing().getBooleanValue());
}
}
Review Comment:
Done in cb67fb1 — added the field Javadoc noting that `null` represents the `DEFAULT` state (fall back to the global configuration) while `TRUE`/`FALSE` are explicit overrides, so future maintainers don't collapse `null` into `false` again.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fesod.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fesod.apache.org
For additional commands, e-mail: commits-help@fesod.apache.org
Re: [PR] fix: fall back to global 1904 windowing when @DateTimeFormat default is used (#1042) [fesod]
Posted by "bengbengbalabalabeng (via GitHub)" <gi...@apache.org>.
bengbengbalabalabeng commented on code in PR #1054:
URL: https://github.com/apache/fesod/pull/1054#discussion_r3922840042
##########
fesod-sheet/src/main/java/org/apache/fesod/sheet/util/DateUtils.java:
##########
@@ -373,6 +375,27 @@ public static String format(BigDecimal date, Boolean use1904windowing, String da
return format(localDateTime, dateFormat);
}
+ /**
+ * Resolve the 1904 windowing flag for a field: the annotation value wins when explicitly set, otherwise fall back
+ * to the global configuration (null-safe, defaults to false).
+ *
+ * @param contentProperty the field's content property, may be null
+ * @param globalConfiguration the global configuration
+ * @return true if dates use the 1904 windowing system
+ */
+ public static boolean resolveUse1904windowing(
Review Comment:
The current method name `resolveUse1904windowing` sounds like an action while it returns a boolean.
How about renaming it to `isDate1904`? Makes it clearer that it is a boolean method. (Reference: Apache POI - `DataFormatter#isDate1904(Cell)`)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fesod.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fesod.apache.org
For additional commands, e-mail: commits-help@fesod.apache.org
Re: [PR] fix: fall back to global 1904 windowing when @DateTimeFormat default is used (#1042) [fesod]
Posted by "delei (via GitHub)" <gi...@apache.org>.
delei merged PR #1054:
URL: https://github.com/apache/fesod/pull/1054
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fesod.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fesod.apache.org
For additional commands, e-mail: commits-help@fesod.apache.org