Commit bb477ffa by H. Väisänen Committed by Tom Tromey

SimpleDateFormat.java (format): Zero pad unless field size is 2.

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.

From-SVN: r69744
parent 270606ac
2003-07-24 H. Visnen <hvaisane@joyx.joensuu.fi>
* java/text/SimpleDateFormat.java (format) [YEAR_FIELD]: Zero pad
unless field size is 2.
2003-07-23 Thomas Fitzsimmons <fitzsim@redhat.com> 2003-07-23 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/java/awt/peer/gtk/GtkTextComponentPeer.java * gnu/java/awt/peer/gtk/GtkTextComponentPeer.java
......
...@@ -430,11 +430,15 @@ public class SimpleDateFormat extends DateFormat ...@@ -430,11 +430,15 @@ public class SimpleDateFormat extends DateFormat
buffer.append(formatData.eras[calendar.get(Calendar.ERA)]); buffer.append(formatData.eras[calendar.get(Calendar.ERA)]);
break; break;
case YEAR_FIELD: case YEAR_FIELD:
temp = String.valueOf(calendar.get(Calendar.YEAR)); // If we have two digits, then we truncate. Otherwise, we
if (p.size < 4) // use the size of the pattern, and zero pad.
buffer.append(temp.substring(temp.length()-2)); if (p.size == 2)
{
temp = String.valueOf(calendar.get(Calendar.YEAR));
buffer.append(temp.substring(temp.length() - 2));
}
else else
buffer.append(temp); withLeadingZeros(calendar.get(Calendar.YEAR), p.size, buffer);
break; break;
case MONTH_FIELD: case MONTH_FIELD:
if (p.size < 3) if (p.size < 3)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment