1 package net.sf.saxon.number; 2 3 9 10 public class Numberer_de extends Numberer_en { 11 12 19 20 protected String ordinalSuffix(String ordinalParam, long number) { 21 return "."; 22 } 23 24 28 29 public String toWords(long number) { 30 if (number >= 1000000000) { 31 long rem = number % 1000000000; 32 long n = number / 100000000; 33 String s = (n==1 ? "Eine" : toWords(n)); 34 return s + " Milliarde" + 35 (rem==0 ? "" : " " + toWords(rem)); 36 } else if (number >= 1000000) { 37 long rem = number % 1000000; 38 long n = number / 1000000; 39 String s = (n==1 ? "Eine" : toWords(n)); 40 return s + " Million" + 41 (rem==0 ? "" : " " + toWords(rem)); 42 } else if (number >= 1000) { 43 long rem = number % 1000; 44 long n = number / 1000; 45 String s = (n==1 ? "Ein" : toWords(n)); 46 return s + "tausend" + (rem==0 ? "" : " " + toWords(rem)); 47 } else if (number >= 100) { 48 long rem = number % 100; 49 long n = number / 100; 50 String s = (n==1 ? "Ein" : toWords(n)); 51 return s + "hundert" + 52 (rem==0 ? "" : (rem>20 ? "" : "und") + toWords(rem, LOWER_CASE)); 53 } else { 54 if (number < 20) return germanUnits[(int)number]; 55 int rem = (int)(number % 10); 56 int tens = (int)number / 10; 57 return (germanUnits[rem]) + 58 (tens==0 ? "" : (rem==0 ? "" : "und") + germanTens[tens]); 59 60 } 61 } 62 63 private static String [] germanUnits = { 64 "", "Eins", "Zwei", "Drei", "Vier", "Fünf", "Sechs", "Sieben", "Acht", "Neun", 65 "Zehn", "Elf", "Zwölf", "Dreizehn", "Vierzehn", "Fünfzehn", "Sechszehn", 66 "Siebzehn", "Achtzehn", "Neunzehn"}; 67 68 private static String [] germanTens = { 69 "", "Zehn", "Zwanzig", "Dreißig", "Vierzig", "Fünfzig", 70 "Sechzig", "Siebzig", "Achtzig", "Neunzig"}; 71 72 75 76 public String toOrdinalWords(String ordinalParam, long number, int wordCase) { 77 String suffix = "e"; 78 if (ordinalParam.equalsIgnoreCase("-er")) { 79 suffix = "er"; 80 } else if (ordinalParam.equalsIgnoreCase("-es")) { 81 suffix = "es"; 82 } else if (ordinalParam.equalsIgnoreCase("-en")) { 83 suffix = "en"; 84 } 85 long mod100 = number % 100; 86 if (number < 20) { 87 String ord = germanOrdinalUnits[(int)number] + suffix; 88 if (wordCase==UPPER_CASE) { 89 return ord.toUpperCase(); 90 } else if (wordCase==LOWER_CASE) { 91 return ord.toLowerCase(); 92 } else { 93 return ord; 94 } 95 } else if (mod100 < 20 && mod100 > 0) { 96 return toWords(number - (mod100), wordCase) + 97 toOrdinalWords(ordinalParam, mod100, 98 (wordCase==TITLE_CASE ? LOWER_CASE : wordCase)); 99 } else { 100 String ending = "st" + suffix; 101 if (wordCase==UPPER_CASE) { 102 ending = ending.toUpperCase(); 103 } 104 return toWords(number, wordCase) + 105 (wordCase==UPPER_CASE ? ending.toUpperCase() : ending); 106 } 107 } 108 109 private static String [] germanOrdinalUnits = { 110 "", "Erst", "Zweit", "Dritt", "Viert", "Fünft", "Sechst", "Siebt", "Acht", "Neunt", 111 "Zehnt", "Elft", "Zwölft", "Dreizehnt", "Vierzehnt", "Fünfzehnt", "Sechszehnt", 112 "Siebzehnt", "Achtzehnt", "Neunzehnt"}; 113 118 124 125 public String monthName(int month, int minWidth, int maxWidth) { 126 String name = germanMonths[month-1]; 127 if (maxWidth < 3) { 128 maxWidth = 3; 129 } 130 if (name.length() > maxWidth) { 131 name = name.substring(0, maxWidth); 132 } 133 while (name.length() < minWidth) { 134 name = name + " "; 135 } 136 return name; 137 } 138 139 private static String [] germanMonths = { 140 "Januar", "Februar", "März", "April", "Mai", "Juni", 141 "Juli", "August", "September", "Oktober", "November", "Dezember" 142 }; 143 144 150 151 public String dayName(int day, int minWidth, int maxWidth) { 152 String name = germanDays[day-1]; 153 if (maxWidth < 10) { 154 name = name.substring(0, 2); 155 } 156 while (name.length() < minWidth) { 157 name = name + " "; 158 } 159 return name; 160 } 161 162 private static String [] germanDays = { 163 "Sunday", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", 164 }; 165 166 175 176 public String getOrdinalSuffixForDateTime(String component) { 177 return "-e"; 178 } 179 180 } 181 182 | Popular Tags |