short patch for SimpleDateFormat

YAMAGUCHI Yuji yamag at distribution.co.jp
Sun Jun 27 01:08:28 PDT 1999


Hi all.

Here is a short patch for SimpleDateFormat class.

Index: SimpleDateFormat.java
===================================================================
RCS file: /home/cvspublic/kaffe/libraries/javalib/java/text/SimpleDateFormat.java,v
retrieving revision 1.11
diff -c -r1.11 SimpleDateFormat.java
*** SimpleDateFormat.java	1999/05/16 23:38:00	1.11
--- SimpleDateFormat.java	1999/06/27 08:38:14
***************
*** 165,170 ****
--- 165,173 ----
  			break;
  		case 'H':
  			val = calendar.get(Calendar.HOUR_OF_DAY);
+ 			if (plen > 1 && val < 10) {
+ 				buf.append('0');
+ 			}
  			buf.append(val);
  			if (pos.field == HOUR_OF_DAY0_FIELD) {
  				pos.begin = cpos;


Here is a test program for this patch.

import java.text.*;
import java.util.*;

class SimpleDateFormatTest {
    public static void main(String[] args) throws Exception {
	Date date = new Date("Sat, 12 Aug 1995 03:30:00 GMT");
	SimpleDateFormat sdf
	    = new SimpleDateFormat ("yyyy.MM.dd 'at' HH:mm:ss zzz");
	sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
	String dateString = sdf.format(date);
	System.out.println(dateString);
    }
}

--
// YAMAGUCHI Yuji - yamag at distribution.co.jp -
// Freeware Distribution Services Co.,Ltd.


More information about the kaffe mailing list