diff options
Diffstat (limited to 'libjava/classpath/java/text/SimpleDateFormat.java')
-rw-r--r-- | libjava/classpath/java/text/SimpleDateFormat.java | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/libjava/classpath/java/text/SimpleDateFormat.java b/libjava/classpath/java/text/SimpleDateFormat.java index 934fb42e2a1..4dcda4f487c 100644 --- a/libjava/classpath/java/text/SimpleDateFormat.java +++ b/libjava/classpath/java/text/SimpleDateFormat.java @@ -40,6 +40,8 @@ exception statement from your version. */ package java.text; +import gnu.java.lang.CPStringBuilder; + import gnu.java.text.AttributedFormatBuffer; import gnu.java.text.FormatBuffer; import gnu.java.text.FormatCharacterIterator; @@ -61,6 +63,8 @@ import java.util.regex.Pattern; /** * SimpleDateFormat provides convenient methods for parsing and formatting * dates using Gregorian calendars (see java.util.GregorianCalendar). + * This class is not thread-safe; external synchronisation should be applied + * if an instance is to be accessed from multiple threads. */ public class SimpleDateFormat extends DateFormat { @@ -139,9 +143,9 @@ public class SimpleDateFormat extends DateFormat */ public String toString() { - StringBuilder builder; + CPStringBuilder builder; - builder = new StringBuilder(getClass().getName()); + builder = new CPStringBuilder(getClass().getName()); builder.append("[field="); builder.append(field); builder.append(", size="); @@ -231,10 +235,16 @@ public class SimpleDateFormat extends DateFormat */ 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. @@ -322,7 +332,7 @@ public class SimpleDateFormat extends DateFormat // Look for the terminating quote. However, if we // see a '', that represents a literal quote and // we must iterate. - StringBuilder buf = new StringBuilder(); + CPStringBuilder buf = new CPStringBuilder(); int oldPos = i + 1; do { @@ -372,7 +382,7 @@ public class SimpleDateFormat extends DateFormat */ public String toString() { - StringBuilder output = new StringBuilder(getClass().getName()); + CPStringBuilder output = new CPStringBuilder(getClass().getName()); output.append("[tokens="); output.append(tokens); output.append(", formatData="); @@ -554,7 +564,7 @@ public class SimpleDateFormat extends DateFormat String oldChars, String newChars) { int len = pattern.length(); - StringBuilder buf = new StringBuilder(len); + CPStringBuilder buf = new CPStringBuilder(len); boolean quoted = false; for (int i = 0; i < len; i++) { @@ -802,7 +812,7 @@ public class SimpleDateFormat extends DateFormat buffer.append (zoneID); break; case RFC822_TIMEZONE_FIELD: - buffer.setDefaultAttribute(DateFormat.Field.RFC822_TIME_ZONE); + buffer.setDefaultAttribute(DateFormat.Field.TIME_ZONE); int pureMinutes = (calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET)) / (1000 * 60); String sign = (pureMinutes < 0) ? "-" : "+"; |