You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2025/10/26 19:55:16 UTC
(commons-lang) 04/05: Clarify implementation with comment
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
commit 3939c0a7996d905133ecde580084b0b59f6be52c
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Oct 26 15:34:55 2025 -0400
Clarify implementation with comment
Use final
---
.../java/org/apache/commons/lang3/time/FastDatePrinter.java | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java b/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java
index 38510332a..9a24831c7 100644
--- a/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java
+++ b/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java
@@ -1127,13 +1127,14 @@ public String format(final Calendar calendar) {
* @see org.apache.commons.lang3.time.DatePrinter#format(java.util.Calendar, Appendable)
*/
@Override
- public <B extends Appendable> B format(Calendar calendar, final B buf) {
- // do not pass in calendar directly, this will cause TimeZone of FastDatePrinter to be ignored
+ public <B extends Appendable> B format(final Calendar calendar, final B buf) {
+ // Don't edit the given Calendar, clone it only if needed.
+ Calendar actual = calendar;
if (!calendar.getTimeZone().equals(timeZone)) {
- calendar = (Calendar) calendar.clone();
- calendar.setTimeZone(timeZone);
+ actual = (Calendar) calendar.clone();
+ actual.setTimeZone(timeZone);
}
- return applyRules(calendar, buf);
+ return applyRules(actual, buf);
}
/* (non-Javadoc)