You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ch...@apache.org on 2015/05/02 20:23:10 UTC

[lang] ZZ format not displaying Z for UTC with OpenJDK 6

Repository: commons-lang
Updated Branches:
  refs/heads/master 4a882e76d -> 0add1e897


ZZ format not displaying Z for UTC with OpenJDK 6


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/0add1e89
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/0add1e89
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/0add1e89

Branch: refs/heads/master
Commit: 0add1e8975336c65513b26123d48b221e2515ddc
Parents: 4a882e7
Author: Chas Honton <ch...@apache.org>
Authored: Sat May 2 11:21:02 2015 -0700
Committer: Chas Honton <ch...@apache.org>
Committed: Sat May 2 11:21:02 2015 -0700

----------------------------------------------------------------------
 .../commons/lang3/time/FastDatePrinter.java     | 22 ++++++--------------
 1 file changed, 6 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/0add1e89/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java
----------------------------------------------------------------------
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 4a20333..093e0f2 100644
--- a/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java
+++ b/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java
@@ -283,7 +283,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
                 if (tokenLen == 1) {
                     rule = TimeZoneNumberRule.INSTANCE_NO_COLON;
                 } else if (tokenLen == 2) {
-                    rule = TimeZoneNumberRule.INSTANCE_ISO_8601;
+                    rule = Iso8601_Rule.ISO8601_HOURS_COLON_MINUTES;
                 } else {
                     rule = TimeZoneNumberRule.INSTANCE_COLON;
                 }
@@ -1179,22 +1179,18 @@ public class FastDatePrinter implements DatePrinter, Serializable {
      * or {@code +/-HH:MM}.</p>
      */
     private static class TimeZoneNumberRule implements Rule {
-        static final TimeZoneNumberRule INSTANCE_COLON = new TimeZoneNumberRule(true, false);
-        static final TimeZoneNumberRule INSTANCE_NO_COLON = new TimeZoneNumberRule(false, false);
-        static final TimeZoneNumberRule INSTANCE_ISO_8601 = new TimeZoneNumberRule(true, true);
+        static final TimeZoneNumberRule INSTANCE_COLON = new TimeZoneNumberRule(true);
+        static final TimeZoneNumberRule INSTANCE_NO_COLON = new TimeZoneNumberRule(false);
         
         final boolean mColon;
-        final boolean mISO8601;
 
         /**
          * Constructs an instance of {@code TimeZoneNumberRule} with the specified properties.
          *
          * @param colon add colon between HH and MM in the output if {@code true}
-         * @param iso8601 create an ISO 8601 format output
          */
-        TimeZoneNumberRule(final boolean colon, final boolean iso8601) {
+        TimeZoneNumberRule(final boolean colon) {
             mColon = colon;
-            mISO8601 = iso8601;
         }
 
         /**
@@ -1210,10 +1206,6 @@ public class FastDatePrinter implements DatePrinter, Serializable {
          */
         @Override
         public void appendTo(final StringBuffer buffer, final Calendar calendar) {
-            if (mISO8601 && calendar.getTimeZone().getID().equals("UTC")) {
-                buffer.append("Z");
-                return;
-            }
             
             int offset = calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET);
 
@@ -1293,14 +1285,12 @@ public class FastDatePrinter implements DatePrinter, Serializable {
          */
         @Override
         public void appendTo(final StringBuffer buffer, final Calendar calendar) {
-            int zoneOffset = calendar.get(Calendar.ZONE_OFFSET);
-            if (zoneOffset == 0) {
+            int offset = calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET);
+            if (offset == 0) {
                 buffer.append("Z");
                 return;
             }
             
-            int offset = zoneOffset + calendar.get(Calendar.DST_OFFSET);
-
             if (offset < 0) {
                 buffer.append('-');
                 offset = -offset;