Name: moC74494 Date: 06/05/98 The getWeekdays method in DateFormatSymbols returns a String[] that contains too many Strings. Specifically, it returns an array of 8 Strings, with strDays[0] being an empty String. getWeekdays should return 7 strings ("Sunday", "Monday", etc) and should be 0-based such that strDays[0] is "Sunday" instead of an empty string. getMonths in DateFormatSymbols returns a String[] that contains too many items. Specifically, it returns 13 Strings where the String at index 12 is empty. Example code follows: //***************************************** //Title: DateFormatSymbols bug //Author: John O'Conner (###@###.###) //Company: QAD, Inc. //***************************************** import java.text.DateFormat; import java.text.DateFormatSymbols; import java.text.SimpleDateFormat; import java.util.Calendar; public class BugDemo { public static void main(String[] args) { DateFormat df = DateFormat.getDateInstance(); Calendar cal = df.getCalendar(); int firstDay = cal.getFirstDayOfWeek(); DateFormatSymbols symbols = ((SimpleDateFormat)df).getDateFormatSymbols(); String strDays[] = symbols.getWeekdays(); String strMonths[] = symbols.getMonths(); System.out.println("strDays array length: " + strDays.length); for (int x = 0; x < strDays.length; x++) { System.out.println("strDays[" + x + "]: " + strDays[x]); } System.out.println("\n\n"); System.out.println("strMonths array length: " + strMonths.length); for (int x = 0; x < strMonths.length; x++) { System.out.println("strMonths[" + x + "]: " + strMonths[x]); } System.exit(0); } } (Review ID: 33091) ======================================================================
|