com.google.gwt.widgetideas.datepicker.client
Class CalendarModel

java.lang.Object
  extended by com.google.gwt.widgetideas.datepicker.client.CalendarModel

public class CalendarModel
extends java.lang.Object

Model used to get calendar information.


Field Summary
static int DAYS_IN_WEEK
           
static int WEEKS_IN_MONTH
           
 
Constructor Summary
CalendarModel()
          Constructor.
 
Method Summary
static boolean computeYearBeforeMonth()
          Is the year before the month?
static java.util.Date copy(java.util.Date date)
          Copies the given date.
 java.util.Date createDate(int dayOfMonth)
          Create a date in the current month at the given day.
 java.lang.String createKeyFromDate(java.util.Date date)
          Create a unique string key for the given date.
static int diffDays(java.util.Date start, java.util.Date finish)
          Returns the number of days between the two dates.
 java.lang.String format(java.util.Date date)
          Format the date using this model's formatter.
 java.lang.String formatCurrentMonth()
          Formats the month in year.
 java.lang.String formatCurrentYear()
          Formats the year.
 java.lang.String formatDayOfMonth(java.util.Date date)
          Format the date's day of month.
 java.lang.String formatDayOfMonth(int dayOfMonth)
          Formats the date's day of month.
 java.lang.String formatDayOfWeek(int dayInWeek)
          Format the day in the week.
 int getCurrentMonth()
          Get the current month.
 java.util.Date getCurrentMonthAndYear()
          Gets the current month and year.
 int getCurrentNumberOfDaysInMonth()
          Returns size of the current month.
 int getCurrentStartingDayOfWeek()
          Gets the current starting day of week.
 int getCurrentYear()
          Gets the current year.
 java.util.Date getFirstDayOfCurrentFirstWeek()
          Gets the first day of the first week in the current month and year.
static int getLocaleStartingDayOfWeek()
          Returns the day of the week on which week starts as per the locale.
 boolean isInCurrentMonth(java.util.Date date)
          Is the date in the current month.
 boolean isWeekend(int dayOfWeek)
          Is the day of the week a weekend?
 java.util.Date parseDate(java.lang.String text)
          Default formatter for date parsing.
 void setCurrentMonthAndYear(java.util.Date currentMonthAndYear)
          Sets the current month and year
 void shiftCurrentMonth(int deltaMonths)
          Shifts the current month by the given number of months.
static void shiftDays(java.util.Date date, int days)
          Shift the date by the given number of days.
static void shiftMonths(java.util.Date date, int months)
          Shift the date by the given number of months.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WEEKS_IN_MONTH

public static final int WEEKS_IN_MONTH
See Also:
Constant Field Values

DAYS_IN_WEEK

public static final int DAYS_IN_WEEK
See Also:
Constant Field Values
Constructor Detail

CalendarModel

public CalendarModel()
Constructor.

Method Detail

computeYearBeforeMonth

public static boolean computeYearBeforeMonth()
Is the year before the month?

Returns:
is the year before the month

copy

public static java.util.Date copy(java.util.Date date)
Copies the given date.

Parameters:
date - the date
Returns:
the copy

diffDays

public static int diffDays(java.util.Date start,
                           java.util.Date finish)
Returns the number of days between the two dates.

Parameters:
start -
finish -
Returns:
the different

getLocaleStartingDayOfWeek

public static int getLocaleStartingDayOfWeek()
Returns the day of the week on which week starts as per the locale. The range between 0 for Sunday and 6 for Saturday.

Returns:
the day of the week on which week starts as per the locale.

shiftDays

public static void shiftDays(java.util.Date date,
                             int days)
Shift the date by the given number of days.

Parameters:
date - the date
days - number of days

shiftMonths

public static void shiftMonths(java.util.Date date,
                               int months)
Shift the date by the given number of months.

Parameters:
date - the date
months - number of months

createDate

public java.util.Date createDate(int dayOfMonth)
Create a date in the current month at the given day.

Parameters:
dayOfMonth - the day in the month
Returns:
the new date

createKeyFromDate

public java.lang.String createKeyFromDate(java.util.Date date)
Create a unique string key for the given date.

Parameters:
date - the date
Returns:
the key

format

public java.lang.String format(java.util.Date date)
Format the date using this model's formatter.

Parameters:
selectedDate -
Returns:

formatCurrentMonth

public java.lang.String formatCurrentMonth()
Formats the month in year.

Returns:
the formatted month in year

formatCurrentYear

public java.lang.String formatCurrentYear()
Formats the year.

Returns:
the formatted year

formatDayOfMonth

public java.lang.String formatDayOfMonth(java.util.Date date)
Format the date's day of month.

Parameters:
date - the date
Returns:
the formated day of month

formatDayOfMonth

public java.lang.String formatDayOfMonth(int dayOfMonth)
Formats the date's day of month.

Returns:
the formatted day of month

formatDayOfWeek

public java.lang.String formatDayOfWeek(int dayInWeek)
Format the day in the week.

Parameters:
dayInWeek - the day in week
Returns:
the formatted day in week

getCurrentMonth

public int getCurrentMonth()
Get the current month.

Returns:
the current month

getCurrentMonthAndYear

public java.util.Date getCurrentMonthAndYear()
Gets the current month and year.

Returns:
the month and year

getCurrentNumberOfDaysInMonth

public int getCurrentNumberOfDaysInMonth()
Returns size of the current month.

Returns:
number of days in the current month

getCurrentStartingDayOfWeek

public int getCurrentStartingDayOfWeek()
Gets the current starting day of week.

Returns:
starting date of week

getCurrentYear

public int getCurrentYear()
Gets the current year.

Returns:
the current year

getFirstDayOfCurrentFirstWeek

public java.util.Date getFirstDayOfCurrentFirstWeek()
Gets the first day of the first week in the current month and year.

Returns:
the first day

isInCurrentMonth

public boolean isInCurrentMonth(java.util.Date date)
Is the date in the current month.

Parameters:
date - date
Returns:
date

isWeekend

public boolean isWeekend(int dayOfWeek)
Is the day of the week a weekend?

Parameters:
dayOfWeek - day of week
Returns:
is the day of week a weekend?

parseDate

public java.util.Date parseDate(java.lang.String text)
Default formatter for date parsing.


setCurrentMonthAndYear

public void setCurrentMonthAndYear(java.util.Date currentMonthAndYear)
Sets the current month and year

Parameters:
currentMonthAndYear - the current month and year

shiftCurrentMonth

public void shiftCurrentMonth(int deltaMonths)
Shifts the current month by the given number of months. The day of the month will be pinned to the original value as far as possible.

Parameters:
deltaMonths - - number of months to be added to the current date