diff options
author | Bryce McKinlay <mckinlay@redhat.com> | 2003-09-28 04:25:44 +0000 |
---|---|---|
committer | Bryce McKinlay <mckinlay@redhat.com> | 2003-09-28 04:25:44 +0000 |
commit | 41e4c84c617b5cade90b73f3d6cd3a4b9ec92fa1 (patch) | |
tree | 045a982bfee5c69420a2dc9e77bafb312ff0300e /java/text/SimpleDateFormat.java | |
parent | 06106b4e70f2c5425bc62636be3a20500a30f8ae (diff) | |
download | classpath-41e4c84c617b5cade90b73f3d6cd3a4b9ec92fa1.tar.gz |
* java/text/DateFormat.java (format): Throw IllegalArgumentException
if j' is not a Number or Date instance.
* java/text/SimpleDateFormat.java (tokens): Make it an ArrayList
instead of Vector.
Diffstat (limited to 'java/text/SimpleDateFormat.java')
-rw-r--r-- | java/text/SimpleDateFormat.java | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/java/text/SimpleDateFormat.java b/java/text/SimpleDateFormat.java index 84bc49be2..804234f78 100644 --- a/java/text/SimpleDateFormat.java +++ b/java/text/SimpleDateFormat.java @@ -39,14 +39,14 @@ exception statement from your version. */ package java.text; +import java.util.ArrayList; import java.util.Calendar; import java.util.Date; -import java.util.Enumeration; import java.util.GregorianCalendar; +import java.util.Iterator; import java.util.Locale; import java.util.TimeZone; import java.util.SimpleTimeZone; -import java.util.Vector; import java.io.ObjectInputStream; import java.io.IOException; @@ -71,7 +71,7 @@ public class SimpleDateFormat extends DateFormat } } - private transient Vector tokens; + private transient ArrayList tokens; private DateFormatSymbols formatData; // formatData private Date defaultCenturyStart; private transient int defaultCentury; @@ -98,7 +98,7 @@ public class SimpleDateFormat extends DateFormat set2DigitYearStart(defaultCenturyStart); // Set up items normally taken care of by the constructor. - tokens = new Vector(); + tokens = new ArrayList(); compileFormat(pattern); } @@ -119,24 +119,24 @@ public class SimpleDateFormat extends DateFormat current = null; if (Character.isLetter(thisChar)) { // Not a valid letter - tokens.addElement(new FieldSizePair(-1,0)); + tokens.add(new FieldSizePair(-1,0)); } else if (thisChar == '\'') { // Quoted text section; skip to next single quote pos = pattern.indexOf('\'',i+1); if (pos == -1) { // This ought to be an exception, but spec does not // let us throw one. - tokens.addElement(new FieldSizePair(-1,0)); + tokens.add(new FieldSizePair(-1,0)); } if ((pos+1 < pattern.length()) && (pattern.charAt(pos+1) == '\'')) { - tokens.addElement(pattern.substring(i+1,pos+1)); + tokens.add(pattern.substring(i+1,pos+1)); } else { - tokens.addElement(pattern.substring(i+1,pos)); + tokens.add(pattern.substring(i+1,pos)); } i = pos; } else { // A special character - tokens.addElement(new Character(thisChar)); + tokens.add(new Character(thisChar)); } } else { // A valid field @@ -144,22 +144,22 @@ public class SimpleDateFormat extends DateFormat current.size++; } else { current = new FieldSizePair(field,1); - tokens.addElement(current); + tokens.add(current); } } } } - + public String toString() { StringBuffer output = new StringBuffer(); - Enumeration e = tokens.elements(); - while (e.hasMoreElements()) { - output.append(e.nextElement().toString()); + Iterator i = tokens.iterator(); + while (i.hasNext()) { + output.append(i.next().toString()); } return output.toString(); } - + /** * Constructs a SimpleDateFormat using the default pattern for * the default locale. @@ -175,7 +175,7 @@ public class SimpleDateFormat extends DateFormat Locale locale = Locale.getDefault(); calendar = new GregorianCalendar(locale); computeCenturyStart(); - tokens = new Vector(); + tokens = new ArrayList(); formatData = new DateFormatSymbols(locale); pattern = (formatData.dateFormats[DEFAULT] + ' ' + formatData.timeFormats[DEFAULT]); @@ -203,7 +203,7 @@ public class SimpleDateFormat extends DateFormat super(); calendar = new GregorianCalendar(locale); computeCenturyStart(); - tokens = new Vector(); + tokens = new ArrayList(); formatData = new DateFormatSymbols(locale); compileFormat(pattern); this.pattern = pattern; @@ -221,7 +221,7 @@ public class SimpleDateFormat extends DateFormat super(); calendar = new GregorianCalendar(); computeCenturyStart (); - tokens = new Vector(); + tokens = new ArrayList(); this.formatData = formatData; compileFormat(pattern); this.pattern = pattern; @@ -264,7 +264,7 @@ public class SimpleDateFormat extends DateFormat */ public void applyPattern(String pattern) { - tokens = new Vector(); + tokens = new ArrayList(); compileFormat(pattern); this.pattern = pattern; } @@ -418,10 +418,10 @@ public class SimpleDateFormat extends DateFormat String temp; calendar.setTime(date); - // go through vector, filling in fields where applicable, else toString - Enumeration e = tokens.elements(); - while (e.hasMoreElements()) { - Object o = e.nextElement(); + // go through ArrayList, filling in fields where applicable, else toString + Iterator i = tokens.iterator(); + while (i.hasNext()) { + Object o = i.next(); if (o instanceof FieldSizePair) { FieldSizePair p = (FieldSizePair) o; int beginIndex = buffer.length(); |