summaryrefslogtreecommitdiff
path: root/libjava/classpath/java/text/SimpleDateFormat.java
diff options
context:
space:
mode:
authorTom Tromey <tromey@gcc.gnu.org>2005-09-23 21:31:04 +0000
committerTom Tromey <tromey@gcc.gnu.org>2005-09-23 21:31:04 +0000
commit1ea63ef8be1cc54dd0de9d82c684713a1dcf1e06 (patch)
tree3ca4b2e68dc14c3128b9c781d23f1d0b1f2bee49 /libjava/classpath/java/text/SimpleDateFormat.java
parent9b044d19517541c95681d35a92dbc81e6e21d94f (diff)
downloadgcc-1ea63ef8be1cc54dd0de9d82c684713a1dcf1e06.tar.gz
Imported Classpath 0.18.
* sources.am, Makefile.in: Updated. * Makefile.am (nat_source_files): Removed natProxy.cc. * java/lang/reflect/natProxy.cc: Removed. * gnu/classpath/jdwp/VMFrame.java, gnu/classpath/jdwp/VMIdManager.java, gnu/classpath/jdwp/VMVirtualMachine.java, java/lang/reflect/VMProxy.java: New files. 2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com> * scripts/makemake.tcl (verbose): Add gnu/java/awt/peer/qt to BC list. 2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com> * gnu/java/net/DefaultContentHandlerFactory.java (getContent): Remove ClasspathToolkit references. 2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com> * gnu/awt/xlib/XCanvasPeer.java: Add new peer methods. * gnu/awt/xlib/XFramePeer.java: Likewise. * gnu/awt/xlib/XGraphicsConfiguration.java: Likewise. 2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com> * Makefile.am (libgcjawt_la_SOURCES): Remove jawt.c. Add classpath/native/jawt/jawt.c. * Makefile.in: Regenerate. * jawt.c: Remove file. * include/Makefile.am (tool_include__HEADERS): Remove jawt.h and jawt_md.h. Add ../classpath/include/jawt.h and ../classpath/include/jawt_md.h. * include/Makefile.in: Regenerate. * include/jawt.h: Regenerate. * include/jawt_md.h: Regenerate. From-SVN: r104586
Diffstat (limited to 'libjava/classpath/java/text/SimpleDateFormat.java')
-rw-r--r--libjava/classpath/java/text/SimpleDateFormat.java117
1 files changed, 73 insertions, 44 deletions
diff --git a/libjava/classpath/java/text/SimpleDateFormat.java b/libjava/classpath/java/text/SimpleDateFormat.java
index 789cb83d86d..c0c4cf68cea 100644
--- a/libjava/classpath/java/text/SimpleDateFormat.java
+++ b/libjava/classpath/java/text/SimpleDateFormat.java
@@ -180,8 +180,8 @@ public class SimpleDateFormat extends DateFormat
* years to be interpreted as representing
* the years between 2004 and 2104.
*
- * @see get2DigitYearStart()
- * @see set2DigitYearStart(java.util.Date)
+ * @see #get2DigitYearStart()
+ * @see #set2DigitYearStart(java.util.Date)
* @see Date
* @serial The start date of the century for parsing two digit years.
* May not be null.
@@ -192,8 +192,8 @@ public class SimpleDateFormat extends DateFormat
* The year at which interpretation of two
* digit years starts.
*
- * @see get2DigitYearStart()
- * @see set2DigitYearStart(java.util.Date)
+ * @see #get2DigitYearStart()
+ * @see #set2DigitYearStart(java.util.Date)
* @serial Ignored.
*/
private transient int defaultCentury;
@@ -204,10 +204,10 @@ public class SimpleDateFormat extends DateFormat
* stored in standardChars. Localized patterns
* are translated to this form.
*
- * @see applyPattern(String)
- * @see applyLocalizedPattern(String)
- * @see toPattern()
- * @see toLocalizedPattern()
+ * @see #applyPattern(String)
+ * @see #applyLocalizedPattern(String)
+ * @see #toPattern()
+ * @see #toLocalizedPattern()
* @serial The non-localized pattern string. May not be null.
*/
private String pattern;
@@ -294,44 +294,73 @@ public class SimpleDateFormat extends DateFormat
int field;
CompiledField current = null;
- for (int i=0; i<pattern.length(); i++) {
- thisChar = pattern.charAt(i);
- field = standardChars.indexOf(thisChar);
- if (field == -1) {
- current = null;
- if ((thisChar >= 'A' && thisChar <= 'Z')
- || (thisChar >= 'a' && thisChar <= 'z')) {
- // Not a valid letter
- throw new IllegalArgumentException("Invalid letter " + thisChar +
- "encountered at character " + i
- + ".");
- } else if (thisChar == '\'') {
- // Quoted text section; skip to next single quote
- pos = pattern.indexOf('\'',i+1);
- if (pos == -1) {
- throw new IllegalArgumentException("Quotes starting at character "
- + i + " not closed.");
+ for (int i = 0; i < pattern.length(); i++)
+ {
+ thisChar = pattern.charAt(i);
+ field = standardChars.indexOf(thisChar);
+ if (field == -1)
+ {
+ current = null;
+ if ((thisChar >= 'A' && thisChar <= 'Z')
+ || (thisChar >= 'a' && thisChar <= 'z'))
+ {
+ // Not a valid letter
+ throw new IllegalArgumentException("Invalid letter "
+ + thisChar +
+ "encountered at character "
+ + i + ".");
+ }
+ else if (thisChar == '\'')
+ {
+ // Quoted text section; skip to next single quote
+ pos = pattern.indexOf('\'', i + 1);
+ // First look for '' -- meaning a single quote.
+ if (pos == i + 1)
+ tokens.add("'");
+ else
+ {
+ // Look for the terminating quote. However, if we
+ // see a '', that represents a literal quote and
+ // we must iterate.
+ StringBuffer buf = new StringBuffer();
+ int oldPos = i + 1;
+ do
+ {
+ if (pos == -1)
+ throw new IllegalArgumentException("Quotes starting at character "
+ + i +
+ " not closed.");
+ buf.append(pattern.substring(oldPos, pos));
+ if (pos + 1 >= pattern.length()
+ || pattern.charAt(pos + 1) != '\'')
+ break;
+ buf.append('\'');
+ oldPos = pos + 2;
+ pos = pattern.indexOf('\'', pos + 2);
+ }
+ while (true);
+ tokens.add(buf.toString());
+ }
+ i = pos;
+ }
+ else
+ {
+ // A special character
+ tokens.add(new Character(thisChar));
+ }
}
- if ((pos+1 < pattern.length()) && (pattern.charAt(pos+1) == '\'')) {
- tokens.add(pattern.substring(i+1,pos+1));
- } else {
- tokens.add(pattern.substring(i+1,pos));
+ else
+ {
+ // A valid field
+ if ((current != null) && (field == current.field))
+ current.size++;
+ else
+ {
+ current = new CompiledField(field, 1, thisChar);
+ tokens.add(current);
+ }
}
- i = pos;
- } else {
- // A special character
- tokens.add(new Character(thisChar));
- }
- } else {
- // A valid field
- if ((current != null) && (field == current.field)) {
- current.size++;
- } else {
- current = new CompiledField(field,1,thisChar);
- tokens.add(current);
- }
}
- }
}
/**
@@ -611,7 +640,7 @@ public class SimpleDateFormat extends DateFormat
* <li>Is using the same century for two digit years.</li>
* </ul>
*
- * @param obj The object to compare for equality against.
+ * @param o The object to compare for equality against.
*
* @return <code>true</code> if the specified object is equal to this object,
* <code>false</code> otherwise.