----- Forwarded message from  -----

To: [email protected]
Subject: FYI: Fix regression in SimpleDateFormat

This reimplements support for 'Z' (RFC822 dates) in SimpleDateFormat
after it was removed during a JAPI fix.

ChangeLog:

2008-03-24  Andrew John Hughes  <[EMAIL PROTECTED]>

        * java/text/SimpleDateFormat.java:
        (standardChars): Corrected.
        (RFC822_TIMEZONE_FIELD): Added.
        (formatWithAttribute(Date,FormatBuffer,FieldPosition)):
        Support RFC822 timezone field ('Z').

-- 
Andrew :)

Support Free Java!
Contribute to GNU Classpath and the OpenJDK
http://www.gnu.org/software/classpath
http://openjdk.java.net
PGP Key: 94EFD9D8 (http://subkeys.pgp.net)
Fingerprint = F8EF F1EA 401E 2E60 15FA  7927 142C 2591 94EF D9D8

Index: java/text/SimpleDateFormat.java
===================================================================
RCS file: /sources/classpath/classpath/java/text/SimpleDateFormat.java,v
retrieving revision 1.58
diff -u -3 -p -u -r1.58 SimpleDateFormat.java
--- java/text/SimpleDateFormat.java     16 Mar 2008 22:44:40 -0000      1.58
+++ java/text/SimpleDateFormat.java     24 Mar 2008 14:43:17 -0000
@@ -233,10 +233,16 @@ public class SimpleDateFormat extends Da
    */
   private static final long serialVersionUID = 4774881970558875024L;
 
-  // This string is specified in the root of the CLDR.  We set it here
-  // rather than doing a DateFormatSymbols(Locale.US).getLocalPatternChars()
-  // since someone could theoretically change those values (though unlikely).
-  private static final String standardChars = "GyMdkHmsSEDFwWahKzYeugAZ";
+  // This string is specified in the Java class libraries.
+  private static final String standardChars = "GyMdkHmsSEDFwWahKzZ";
+
+  /**  
+   * Represents the position of the RFC822 timezone pattern character
+   * in the array of localized pattern characters.  In the
+   * U.S. locale, this is 'Z'.  The value is the offset of the current
+   * time from GMT e.g. -0500 would be five hours prior to GMT.
+   */  
+  private static final int RFC822_TIMEZONE_FIELD = 18;
 
   /**
    * Reads the serialized version of this object.
@@ -803,6 +809,18 @@ public class SimpleDateFormat extends Da
                  (isDST, cf.getSize() > 3 ? TimeZone.LONG : TimeZone.SHORT);
                buffer.append (zoneID);
                break;
+             case RFC822_TIMEZONE_FIELD:
+               buffer.setDefaultAttribute(DateFormat.Field.TIME_ZONE);
+               int pureMinutes = (calendar.get(Calendar.ZONE_OFFSET) +
+                                  calendar.get(Calendar.DST_OFFSET)) / (1000 * 
60);
+               String sign = (pureMinutes < 0) ? "-" : "+";
+                pureMinutes = Math.abs(pureMinutes);
+               int hours = pureMinutes / 60;
+               int minutes = pureMinutes % 60;
+               buffer.append(sign);
+               withLeadingZeros(hours, 2, buffer);
+               withLeadingZeros(minutes, 2, buffer);
+               break;
              default:
                throw new IllegalArgumentException ("Illegal pattern character 
" +
                                                    cf.getCharacter());




----- End forwarded message -----

-- 
Andrew :)

Support Free Java!
Contribute to GNU Classpath and the OpenJDK
http://www.gnu.org/software/classpath
http://openjdk.java.net
PGP Key: 94EFD9D8 (http://subkeys.pgp.net)
Fingerprint = F8EF F1EA 401E 2E60 15FA  7927 142C 2591 94EF D9D8

Attachment: signature.asc
Description: Digital signature

Reply via email to