Created
February 10, 2014 18:01
-
-
Save edgardleal/8920979 to your computer and use it in GitHub Desktop.
Arrays with descriptions of days of month , days of week and hours of day
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NumbersNames{ | |
private static final String[] tensNames = { "", " ten", " twenty", | |
" thirty", " forty", " fifty", " sixty", " seventy", " eighty", | |
" ninety" }; | |
private static final String[] numNames = { "zero", " one", " two", | |
" three", " four", " five", " six", " seven", " eight", " nine", | |
" ten", " eleven", " twelve", " thirteen", " fourteen", " fifteen", | |
" sixteen", " seventeen", " eighteen", " nineteen" }; | |
private static String[] daysOfWeek = { "", "Sunday", "Monday", "Tuesday", | |
"Wednesday", "Thursday", "Friday", "Saturday" }; | |
public static void printHoursOfDay() { | |
for (int i = 0; i < 24; i++) { | |
int ten = Math.round(i / 10); | |
String name = (ten > 01 ? (tensNames[ten].toUpperCase() + "_") : "") | |
+ numNames[i % 20].toUpperCase().trim(); | |
System.out.println(String | |
.format("case %d : return %s; \n", i, name)); | |
} | |
} | |
public static void printDaysOfMonth() { | |
for (int i = 1; i < 32; i++) { | |
int ten = Math.round(i / 10); | |
String name = (ten > 01 ? (tensNames[ten].toUpperCase() + "_") : "") | |
+ numNames[i % 20].toUpperCase().trim(); | |
System.out.println(String.format("%s(%d),", name, i)); | |
} | |
} | |
public static void printSwitchDaysOfMonth() { | |
for (int i = 1; i < 32; i++) { | |
int ten = Math.round(i / 10); | |
String name = (ten > 01 ? (tensNames[ten].toUpperCase() + "_") : "") | |
+ numNames[i % 20].toUpperCase().trim(); | |
System.out.println(String.format("case %d : return %s;", i, name)); | |
} | |
} | |
public static void printDaysOfWeek() { | |
for (int i = 1; i < 8; i++) { | |
String name = daysOfWeek[i].toUpperCase().trim(); | |
System.out.println(String.format("%s(%d),", name, i)); | |
} | |
} | |
public static void printSwitchDaysOfWeek() { | |
for (int i = 1; i < 8; i++) { | |
String name = daysOfWeek[i].toUpperCase().trim(); | |
System.out.println(String.format("case %d : return %s;", i, name)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment