Class CalendarModel
- java.lang.Object
-
- com.google.gwt.user.datepicker.client.CalendarModel
-
public class CalendarModel extends java.lang.Object
Model used to get calendar information forDatePicker
and its subclasses.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DAYS_IN_WEEK
Number of days normally displayed in a week.static int
MONTHS_IN_YEAR
static int
WEEKS_IN_MONTH
The number of weeks normally displayed in a month.
-
Constructor Summary
Constructors Constructor Description CalendarModel()
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
formatCurrentMonth()
Formats the current specified month.java.lang.String
formatCurrentMonthAndYear()
Format the current month and year in the current locale.java.lang.String
formatCurrentYear()
Formats the current specified year.java.lang.String
formatDayOfMonth(java.util.Date date)
Formats a date's day of month.java.lang.String
formatDayOfWeek(int dayInWeek)
Format a day in the week.java.lang.String
formatMonth(int month)
Format a month in the year.java.util.Date
getCurrentFirstDayOfFirstWeek()
Gets the first day of the first week in the currently specified month.java.util.Date
getCurrentMonth()
Gets the date representation of the currently specified month.protected DateTimeFormat
getDayOfMonthFormatter()
Gets the date of month formatter.protected DateTimeFormat
getDayOfWeekFormatter()
Gets the day of week formatter.protected DateTimeFormat
getMonthAndYearFormatter()
Gets the month and year formatter.protected DateTimeFormat
getMonthFormatter()
Gets the month formatter.protected DateTimeFormat
getYearFormatter()
Gets the year formatter.boolean
isInCurrentMonth(java.util.Date date)
Is a date in the currently specified month?protected boolean
isMonthBeforeYear()
Returnstrue
if the month is before year in the date formatter in current locale.protected void
refresh()
Refresh the current model as needed.void
setCurrentMonth(java.util.Date currentDate)
Sets the currently specified date.void
shiftCurrentMonth(int deltaMonths)
Shifts the currently specified date by the given number of months.
-
-
-
Field Detail
-
WEEKS_IN_MONTH
public static final int WEEKS_IN_MONTH
The number of weeks normally displayed in a month.- See Also:
- Constant Field Values
-
DAYS_IN_WEEK
public static final int DAYS_IN_WEEK
Number of days normally displayed in a week.- See Also:
- Constant Field Values
-
MONTHS_IN_YEAR
public static final int MONTHS_IN_YEAR
- See Also:
- Constant Field Values
-
-
Method Detail
-
formatCurrentMonth
public java.lang.String formatCurrentMonth()
Formats the current specified month. For example "September" in English.- Returns:
- the formatted month
-
formatCurrentMonthAndYear
public java.lang.String formatCurrentMonthAndYear()
Format the current month and year in the current locale. For example, "Jan 2013" in English.- Returns:
- the formatted month and year
-
formatCurrentYear
public java.lang.String formatCurrentYear()
Formats the current specified year. For example "2012".- Returns:
- the formatted year
-
formatDayOfMonth
public java.lang.String formatDayOfMonth(java.util.Date date)
Formats a date's day of month. For example "1".- Parameters:
date
- the date- Returns:
- the formated day of month
-
formatDayOfWeek
public java.lang.String formatDayOfWeek(int dayInWeek)
Format a day in the week. So, for example "Monday".- Parameters:
dayInWeek
- the day in week to format- Returns:
- the formatted day in week
-
formatMonth
public java.lang.String formatMonth(int month)
Format a month in the year. So, for example "January".- Parameters:
month
- A number from 0 (for January) to 11 (for December) identifying the month wanted.- Returns:
- the formatted month
-
getCurrentFirstDayOfFirstWeek
public java.util.Date getCurrentFirstDayOfFirstWeek()
Gets the first day of the first week in the currently specified month.- Returns:
- the first day
-
getCurrentMonth
public java.util.Date getCurrentMonth()
Gets the date representation of the currently specified month. Used to access both the month and year information.- Returns:
- the month and year
-
isInCurrentMonth
public boolean isInCurrentMonth(java.util.Date date)
Is a date in the currently specified month?- Parameters:
date
- the date- Returns:
- date
-
setCurrentMonth
public void setCurrentMonth(java.util.Date currentDate)
Sets the currently specified date.- Parameters:
currentDate
- the currently specified date
-
shiftCurrentMonth
public void shiftCurrentMonth(int deltaMonths)
Shifts the currently specified date 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
-
getDayOfMonthFormatter
protected DateTimeFormat getDayOfMonthFormatter()
Gets the date of month formatter.- Returns:
- the day of month formatter
-
getDayOfWeekFormatter
protected DateTimeFormat getDayOfWeekFormatter()
Gets the day of week formatter.- Returns:
- the day of week formatter
-
getMonthAndYearFormatter
protected DateTimeFormat getMonthAndYearFormatter()
Gets the month and year formatter.- Returns:
- the month and year formatter
-
getMonthFormatter
protected DateTimeFormat getMonthFormatter()
Gets the month formatter.- Returns:
- the month formatter
-
getYearFormatter
protected DateTimeFormat getYearFormatter()
Gets the year formatter.- Returns:
- the year formatter
-
isMonthBeforeYear
protected boolean isMonthBeforeYear()
Returnstrue
if the month is before year in the date formatter in current locale.
-
refresh
protected void refresh()
Refresh the current model as needed.
-
-