summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/text/SimpleDateFormat.java82
1 files changed, 47 insertions, 35 deletions
diff --git a/java/text/SimpleDateFormat.java b/java/text/SimpleDateFormat.java
index f1fc092d3..12ea95484 100644
--- a/java/text/SimpleDateFormat.java
+++ b/java/text/SimpleDateFormat.java
@@ -294,44 +294,56 @@ 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);
+ if (pos == -1)
+ {
+ throw new IllegalArgumentException("Quotes starting at character "
+ + i + " not closed.");
+ }
+ 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));
+ 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);
- }
}
- }
}
/**