Skip to content

Instantly share code, notes, and snippets.

@edgardleal
Created February 10, 2014 18:01
Show Gist options
  • Save edgardleal/8920979 to your computer and use it in GitHub Desktop.
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
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