// TimeFormatter.java // $Id: TimeFormatter.java,v 1.4 1998/01/22 14:25:41 bmahe Exp $ // (c) COPYRIGHT MIT and INRIA, 1996. // Please first read the full copyright statement in file COPYRIGHT.html package org.w3c.util ; import java.util.* ; /** * This class does date formatting using the same format strings accepted by the * strftime(3) UNIX call. This class has static methods only. * @author Antonio Ramírez */ public class TimeFormatter { private static String[] fullWeekDays = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" } ; private static String[] abrWeekDays = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" } ; private static String[] fullMonths = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" } ; private static String[] abrMonths = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" } ; /** * Format the given date as a string, according to the given * format string. * The format string is of the form used by the strftime(3) UNIX * call. * @param date The date to format * @param format The formatting string * @return the String with the formatted date. */ public static String format(Date date,String format) { StringBuffer buf = new StringBuffer(50) ; char ch; for(int i=0;i