18 package org.turro.html.calendar;
20 import java.text.SimpleDateFormat;
21 import java.util.ArrayList;
22 import java.util.Calendar;
23 import java.util.List;
24 import java.util.Locale;
37 date.set(Calendar.DAY_OF_MONTH, 1);
38 int first = date.getFirstDayOfWeek();
39 while(date.get(Calendar.DAY_OF_WEEK) != first)
40 date.add(Calendar.DAY_OF_MONTH, -1);
47 public static String[]
getDayNames(Locale locale,
boolean small) {
48 Calendar date = Calendar.getInstance(locale);
49 SimpleDateFormat fmtDayWeek =
new SimpleDateFormat((small ?
"EE" :
"EEEE"), locale);
50 int curr = date.getFirstDayOfWeek(), idx = 0;
51 date.set(Calendar.DAY_OF_WEEK, curr);
52 List dayNames =
new ArrayList();
54 dayNames.add(fmtDayWeek.format(date.getTime()));
57 if(curr > 7) curr = 1;
58 date.set(Calendar.DAY_OF_WEEK, curr);
60 return (String[])dayNames.toArray(
new String[0]);
68 Calendar date = Calendar.getInstance(locale);
69 SimpleDateFormat fmtMonth =
new SimpleDateFormat((small ?
"MMM" :
"MMMM"), locale);
70 List monthNames =
new ArrayList();
71 for(
int m = 0; m < 12; m++) {
72 date.set(Calendar.MONTH, m);
73 monthNames.add(fmtMonth.format(date.getTime()));
75 return (String[])monthNames.toArray(
new String[0]);
static String[] getMonthNames(Locale locale, boolean small)
static String[] getDayNames(Locale locale, boolean small)
static String[] getDayNames(Locale locale)
static String[] getMonthNames(Locale locale)
static void positionFirstCell(Calendar date)