1 10 package org.mmbase.util; 11 12 import java.util.*; 13 import java.text.*; 14 import org.mmbase.util.logging.*; 15 16 21 public class RFC1123 { 22 23 static Logger log = Logging.getLoggerInstance(RFC1123.class.getName()); 25 26 27 private static DateFormat formatter; 28 29 static { 30 formatter = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US); 31 formatter.setTimeZone(TimeZone.getTimeZone("GMT")); 32 } 33 34 38 private static String days[]={ "Sun, ","Mon, ","Tue, ","Wed, ","Thu, ","Fri, ","Sat, ","Sun, " }; 39 40 45 public static String makeDateV1(Date d) { 46 return days[d.getDay()]+d.toGMTString(); 47 } 48 52 public static String makeDateV2(Date d) { 53 return makeDate(d); 54 } 55 56 59 public static String makeDate(Date d) { 60 return formatter.format(d); 61 } 62 63 64 67 public static void main(String args[]) { 68 log.info("Date "+makeDateV1(new Date())); 69 log.info("Date "+makeDateV2(new Date())); 70 log.info("Date(corr) "+makeDateV1(new Date(DateSupport.currentTimeMillis()))); 71 log.info("Date(corr) "+makeDateV2(new Date(DateSupport.currentTimeMillis()))); 72 } 73 74 } 75 | Popular Tags |