aboutsummaryrefslogtreecommitdiff
path: root/libjava/java
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2003-07-24 15:43:04 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2003-07-24 15:43:04 +0000
commita7356729e855167ec178d457bf49ac7f1d90f758 (patch)
tree62f8c3ebc4be39738e23865f9c0d1586dd49db48 /libjava/java
parent10d53a73b478b93d2bb8a551d7ace9372945bad8 (diff)
2003-07-24 H. V�is�nen <hvaisane@joyx.joensuu.fi>
* java/text/SimpleDateFormat.java (format) [YEAR_FIELD]: Zero pad unless field size is 2. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@69744 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java')
-rw-r--r--libjava/java/text/SimpleDateFormat.java12
1 files changed, 8 insertions, 4 deletions
diff --git a/libjava/java/text/SimpleDateFormat.java b/libjava/java/text/SimpleDateFormat.java
index 67523e1628d..b43c6cd86d4 100644
--- a/libjava/java/text/SimpleDateFormat.java
+++ b/libjava/java/text/SimpleDateFormat.java
@@ -430,11 +430,15 @@ public class SimpleDateFormat extends DateFormat
buffer.append(formatData.eras[calendar.get(Calendar.ERA)]);
break;
case YEAR_FIELD:
- temp = String.valueOf(calendar.get(Calendar.YEAR));
- if (p.size < 4)
- buffer.append(temp.substring(temp.length()-2));
+ // If we have two digits, then we truncate. Otherwise, we
+ // use the size of the pattern, and zero pad.
+ if (p.size == 2)
+ {
+ temp = String.valueOf(calendar.get(Calendar.YEAR));
+ buffer.append(temp.substring(temp.length() - 2));
+ }
else
- buffer.append(temp);
+ withLeadingZeros(calendar.get(Calendar.YEAR), p.size, buffer);
break;
case MONTH_FIELD:
if (p.size < 3)