1 16 17 package org.apache.log4j.helpers; 18 19 import java.util.Calendar ; 20 import java.util.TimeZone ; 21 import java.util.Date ; 22 import java.text.FieldPosition ; 23 import java.text.ParsePosition ; 24 import java.text.DateFormatSymbols ; 25 26 33 public class DateTimeDateFormat extends AbsoluteTimeDateFormat { 34 35 String [] shortMonths; 36 37 public 38 DateTimeDateFormat() { 39 super(); 40 shortMonths = new DateFormatSymbols ().getShortMonths(); 41 } 42 43 public 44 DateTimeDateFormat(TimeZone timeZone) { 45 this(); 46 setCalendar(Calendar.getInstance(timeZone)); 47 } 48 49 55 public 56 StringBuffer format(Date date, StringBuffer sbuf, 57 FieldPosition fieldPosition) { 58 59 calendar.setTime(date); 60 61 int day = calendar.get(Calendar.DAY_OF_MONTH); 62 if(day < 10) 63 sbuf.append('0'); 64 sbuf.append(day); 65 sbuf.append(' '); 66 sbuf.append(shortMonths[calendar.get(Calendar.MONTH)]); 67 sbuf.append(' '); 68 69 int year = calendar.get(Calendar.YEAR); 70 sbuf.append(year); 71 sbuf.append(' '); 72 73 return super.format(date, sbuf, fieldPosition); 74 } 75 76 79 public 80 Date parse(java.lang.String s, ParsePosition pos) { 81 return null; 82 } 83 } 84 | Popular Tags |