1 15 package org.apache.tapestry.workbench.table; 16 17 import java.io.Serializable ; 18 import java.text.SimpleDateFormat ; 19 import java.util.GregorianCalendar ; 20 import java.util.Locale ; 21 22 26 public class VerbosityRating implements Serializable 27 { 28 private static final long serialVersionUID = 1L; 29 30 37 public static int calculateVerbosity(Locale objLocale) 38 { 39 int nWeekDayVerbosity = calculateWeekDayVerbosity(objLocale); 40 int nMonthVerbosity = calculateMonthVerbosity(objLocale); 41 return nWeekDayVerbosity + nMonthVerbosity; 42 } 43 44 public static int calculateWeekDayVerbosity(Locale objLocale) 45 { 46 SimpleDateFormat objWeekDay = new SimpleDateFormat ("EEEE", objLocale); 47 48 GregorianCalendar objCalendar = new GregorianCalendar (); 49 objCalendar.set(GregorianCalendar.YEAR, 2000); 50 objCalendar.set(GregorianCalendar.MONTH, 0); 51 objCalendar.set(GregorianCalendar.DATE, 1); 52 53 int nCount = 0; 54 for (int i = 0; i < 7; i++) 55 { 56 String strWeekDay = objWeekDay.format(objCalendar.getTime()); 57 nCount += strWeekDay.length(); 58 objCalendar.add(GregorianCalendar.DATE, 1); 59 } 60 61 return nCount; 62 } 63 64 public static int calculateMonthVerbosity(Locale objLocale) 65 { 66 SimpleDateFormat objMonth = new SimpleDateFormat ("MMMM", objLocale); 67 68 GregorianCalendar objCalendar = new GregorianCalendar (); 69 objCalendar.set(GregorianCalendar.YEAR, 2000); 70 objCalendar.set(GregorianCalendar.MONTH, 0); 71 objCalendar.set(GregorianCalendar.DATE, 1); 72 73 int nCount = 0; 74 for (int i = 0; i < 12; i++) 75 { 76 String strMonth = objMonth.format(objCalendar.getTime()); 77 nCount += strMonth.length(); 78 objCalendar.add(GregorianCalendar.MONTH, 1); 79 } 80 81 return nCount; 82 } 83 84 public static void main(String [] arrArgs) 85 { 86 int nMax = 0; 87 int nMin = 1000; 88 89 System.out.println("Starting"); 90 91 Locale [] arrLocales = Locale.getAvailableLocales(); 92 for (int i = 0; i < arrLocales.length; i++) 93 { 94 Locale objLocale = arrLocales[i]; 95 int nRating = calculateVerbosity(objLocale); 96 if (nRating > nMax) 97 nMax = nRating; 98 if (nRating < nMin) 99 nMin = nRating; 100 } 101 102 System.out.println("Min: " + nMin); 103 System.out.println("Max: " + nMax); 104 } 105 106 } 107 | Popular Tags |