public class DatePicker
extends java.lang.Object
date,
you would add inputs with names date_year, date_month, date_day,
date_hour, date_minute, and date_am_pm to the form. All this form
variables need to be declared as type java.util.Integer
In your Struts action, you can initialize the form fields with
Date d = ...;
DynaActionForm dynaForm = ...;
DatePicker p = new DatePicker("date", timeZone, locale, yearDirection);
p.setDate(d);
p.writeForm(dynaForm.getMap());
Once the form is submitted, you can extract the date with
DynaActionForm dynaForm = ...;
DatePicker p = new DatePicker("date", timeZone, locale, yearDirection);
p.readForm(dynaForm.getMap());
Date result = p.getDate();
if ( result == null ) {
... tell user that date was incorrect ...
}
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
AM_PM |
static java.lang.String |
DAY |
static java.lang.String |
HOUR |
static java.lang.String |
MINUTE |
static java.lang.String |
MONTH |
static java.lang.String |
USE_DATE
Typical form field when dealing with a date picker.
|
static java.lang.String |
YEAR |
static int |
YEAR_RANGE_NEGATIVE |
static int |
YEAR_RANGE_POSITIVE |
| Constructor and Description |
|---|
DatePicker(java.lang.String name0,
java.util.Locale locale0,
int yearRangeDirection0)
Create a new date picker that extracts fields prefixed with
name0 + "_" and works with the given locale. |
DatePicker(java.lang.String name0,
java.util.TimeZone tz,
java.util.Locale locale0,
int yearRangeDirection0)
Create a new date picker that extracts fields prefixed with
name0 + "_" and works with the given time zone
and locale. |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Integer |
getAmPm()
Return
0 to indicate AM and 1
to indicate PM. |
java.util.Calendar |
getCalendar()
The calendar underlying this date picker.
|
java.util.Date |
getDate() |
java.text.DateFormatSymbols |
getDateFormatSymbols()
Return date format symbols for the locale associated with this date picker.
|
java.lang.Integer |
getDay()
Return the day, a number from 1 to 31.
|
boolean |
getDisableDate()
Returns disableDate property
|
boolean |
getDisableTime()
Returns disableTime property
|
java.lang.Integer |
getHour()
Return the hour, a number between 1 and 12 if
isLatin
is true, and a number from 0 to 23 otherwise. |
java.lang.Integer |
getHourOfDay() |
int[] |
getHourRange()
Get the range of valid hour values, 1 to 12 if
isLatin is
true and 0 to 23 otherwise. |
java.util.Locale |
getLocale() |
java.lang.Integer |
getMinute()
Return the minute, a number from 0 to 59.
|
java.lang.Integer |
getMonth()
Return the month, a number from 0 to 12.
|
java.lang.String |
getName()
Return the name of this picker.
|
java.lang.Integer |
getYear()
Return the year
|
int[] |
getYearRange()
Get a list of years for display.
|
int |
getYearRangeDirection() |
boolean |
isDayBeforeMonth()
Return
true if in the given locale the day
is written before the month, false otherwise. |
boolean |
isLatin()
Return
true if the locale uses 12 hour time formats
with the additional am/pm designation (like certain anglo-saxon countries). |
void |
readForm(org.apache.struts.action.DynaActionForm form)
Reads the form fields to populate date fields.
|
void |
readMap(java.util.Map map)
Parse the values in
map into the internal date. |
void |
setAmPm(java.lang.Integer v)
Set am or pm
|
void |
setDate(java.util.Date date)
Set the internal date of the picker to
date |
void |
setDay(java.lang.Integer v)
Set the day.
|
void |
setDisableDate()
Set disableDate property (Picker doesn't offer to set date)
|
void |
setDisableTime()
Set disableTime property (Picker doesn't offer to set time)
|
void |
setHour(java.lang.Integer v)
Set the hour
|
void |
setHourOfDay(java.lang.Integer v)
set the hour of the day
This also sets the am/pm flag
|
void |
setMinute(java.lang.Integer v)
Set the minute
|
void |
setMonth(java.lang.Integer v)
Set the month.
|
void |
setYear(java.lang.Integer v)
Set the year
|
void |
writeToForm(org.apache.struts.action.DynaActionForm form)
Write the internal date into
form. |
void |
writeToMap(java.util.Map map)
Write the internal date into
map. |
public static final java.lang.String USE_DATE
StrutsDelegate,
Constant Field Valuespublic static final java.lang.String YEAR
public static final java.lang.String MONTH
public static final java.lang.String DAY
public static final java.lang.String HOUR
public static final java.lang.String MINUTE
public static final java.lang.String AM_PM
public static final int YEAR_RANGE_POSITIVE
public static final int YEAR_RANGE_NEGATIVE
public DatePicker(java.lang.String name0,
java.util.TimeZone tz,
java.util.Locale locale0,
int yearRangeDirection0)
name0 + "_" and works with the given time zone
and locale.name0 - the prefix for the subfields for the date pickertz - the timezone in which values are to be interpretedlocale0 - the locale to useyearRangeDirection0 - direction of the year range to use.
YEAR_RANGE_POSATIVE means the year selection will go from now
until YEAR_RANGE_SIZE in the future (2005-2010). YEAR_RANGE_NEGATIVE
will include a range from now until YEAR_RANGE_SIZE in the
past (2000 - 2005)public DatePicker(java.lang.String name0,
java.util.Locale locale0,
int yearRangeDirection0)
name0 + "_" and works with the given locale.name0 - the prefix for the subfields for the date pickerlocale0 - the locale to useyearRangeDirection0 - direction of the year range to use.
YEAR_RANGE_POSATIVE means the year selection will go from now
until YEAR_RANGE_SIZE in the future (2005-2010). YEAR_RANGE_NEGATIVE
will include a range from now until YEAR_RANGE_SIZE in the
past (2000 - 2005)public boolean isLatin()
true if the locale uses 12 hour time formats
with the additional am/pm designation (like certain anglo-saxon countries).
A return value of false indicates that the locale uses
a 24 hour clock.true if the locale uses 12 hour times with am/pm,
false if it uses a 24 hour clock.public boolean isDayBeforeMonth()
true if in the given locale the day
is written before the month, false otherwise.true if in the given locale the day
is written before the month, false otherwise.public java.lang.String getName()
public java.lang.Integer getMonth()
public java.lang.Integer getDay()
public java.lang.Integer getYear()
public java.lang.Integer getHour()
isLatin
is true, and a number from 0 to 23 otherwise.isLatin
is true, and a number from 0 to 23 otherwise.public java.lang.Integer getHourOfDay()
public java.lang.Integer getMinute()
public java.lang.Integer getAmPm()
0 to indicate AM and 1
to indicate PM.0 to indicate AM and 1
to indicate PM.public void setMonth(java.lang.Integer v)
v - the month, a number from 0 to 11public void setDay(java.lang.Integer v)
v - the day, a number from 1 to 31public void setYear(java.lang.Integer v)
v - the yearpublic void setHour(java.lang.Integer v)
v - the hourgetHour()public void setHourOfDay(java.lang.Integer v)
v - the hour (0 to 23)public void setMinute(java.lang.Integer v)
v - the minute, a number from 0 to 59public void setAmPm(java.lang.Integer v)
v - 0 to indicate AM and 1
to indicate PM.public int[] getYearRange()
YEAR_RANGE_SIZE years down.public int[] getHourRange()
isLatin is
true and 0 to 23 otherwise.isLatin is
true and 0 to 23 otherwise.public java.util.Date getDate()
null if the date is invalid.public void setDate(java.util.Date date)
datedate - the date to which the internal date should be set topublic java.util.Calendar getCalendar()
public void readMap(java.util.Map map)
map into the internal date. The
map must map the names of the date widget fields like
date_year etc. to Integer or parsable
String values.
If the map does not contain all of the required fields, the default
date of now will be used.map - a map from date widget field names to Integer
or String values.public void readForm(org.apache.struts.action.DynaActionForm form)
form - The form containing date picker fields.public void writeToMap(java.util.Map map)
map. The
map will map the names of the date widget fields like
date_year etc. to Integer values.map - a map from date widget field names to Integer valuespublic void writeToForm(org.apache.struts.action.DynaActionForm form)
form. The
form will map the names of the date widget fields like
date_year etc. to Integer values.form - a dyna action form with date widget field names
to Integer valuespublic java.text.DateFormatSymbols getDateFormatSymbols()
public int getYearRangeDirection()
public void setDisableTime()
public boolean getDisableTime()
public void setDisableDate()
public boolean getDisableDate()
public java.util.Locale getLocale()