|
JDatePicker v4.3 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.standbysoft.component.date.DefaultDateModel
A default implementation for a date model.
| Field Summary | |
protected static int[] |
FIELDS
|
| Constructor Summary | |
DefaultDateModel()
Creates a date model that represents the current system date. |
|
| Method Summary | |
void |
addDateListener(DateListener listener)
Registers a new date listener to the model. |
void |
clear(int field)
Clears a specified field, meaning that it contains no value. |
protected void |
fireDateChanged(DateEvent evt)
|
protected void |
fireDateFieldChanged(DateEvent evt)
|
protected void |
fireDateFieldCleared(DateEvent evt)
|
int |
get(int field)
Returns the value of a specified field. |
int |
getAutoCenturyYear()
Determines the reference year used to build the long year from a short one. |
java.util.Date |
getDate()
Returns the date wrapped by this model. |
int |
getMaximumAllowed(int field,
java.util.Date date)
Returns the highest acceptable value for a certain field. |
int |
getMinimumAllowed(int field,
java.util.Date date)
Always returns 0. |
java.util.TimeZone |
getTimeZone()
Returns the time zone used by this model. |
boolean |
isAutoCentury()
Determines whether century is automatically added to the year field if its value is less than 100. |
boolean |
isDateValid()
All dates represented by this model are considered valid because invalid values are not allowed in the first place. |
boolean |
isSet(int field)
Determines whether a specified field is cleared or not. |
boolean |
isUsed(int field)
Determines whether a specified field is part of the date. |
void |
removeDateListener(DateListener listener)
Removes a specified date listener from this model. |
void |
set(int field,
int val)
Modifies the value of a specified date field. |
void |
setAutoCentury(boolean auto)
Specifies whether century is automatically added to the year field if its value is less than 100. |
void |
setAutoCenturyYear(int year)
Specifies the year used to build the long year when short years are used. |
void |
setDate(java.util.Date date)
Specifies a new date to be represented by this model that can later be modified field by field. |
void |
setTimeZone(java.util.TimeZone zone)
Specifies the time zone for this model. |
void |
setUsed(int field,
boolean used)
Specifies whether a certain field is used to construct the actual date represented here. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected static int[] FIELDS
| Constructor Detail |
public DefaultDateModel()
| Method Detail |
public void setTimeZone(java.util.TimeZone zone)
DateModelSpecifies the time zone for this model. This parameter is very important if you need to know the values of the date fields in a certain time zone. If no time zone is specified, then the default one is used.
The dates that come in and out of this model are standard (GMT) while the values of the date fields depend on the time zone. If the time zone is changed, so do the internal date fields in order to reflect this change.
setTimeZone in interface DateModelzone - new time zone for this modelDateModel.get(int)public java.util.TimeZone getTimeZone()
DateModel
getTimeZone in interface DateModelDateModel.setTimeZone(TimeZone)public boolean isSet(int field)
DateModel
isSet in interface DateModelfield - field that is tested. Possible values are: Calendar.YEAR,
Calendar.MONTH, Calendar.MINUTE, etc.
true if the field is not cleared; false otherwiseDateModel.clear(int)public void clear(int field)
DateModel
clear in interface DateModelfield - field that is cleared. Possible values are: Calendar.YEAR,
Calendar.MONTH, Calendar.MINUTE, etc.DateModel.isSet(int)
public int getMinimumAllowed(int field,
java.util.Date date)
0. The minimum accepted value for this default
implementation is aloways 0.
getMinimumAllowed in interface DateModelfield - field that is testeddate - context object that can offer additional information about the
other date fields
0
for the minute fieldDateModel.set(int, int)
public int getMaximumAllowed(int field,
java.util.Date date)
DateModel
getMaximumAllowed in interface DateModelfield - field that is testeddate - context object that can offer additional information about the
other date fields
59
for the minute fieldDateModel.set(int, int)
public void set(int field,
int val)
DateModel
set in interface DateModelfield - date field that is modified. Possible values are: Calendar.YEAR,
Calendar.MONTH, Calendar.MINUTE, etc.val - the new date field value. Various implementations could handle
this value differently. Some may allow and some may not allow out of range values.DateModel.getMinimumAllowed(int, Date),
DateModel.getMaximumAllowed(int, Date)public int get(int field)
DateModel
get in interface DateModelfield - date field that is tested. Possible values are: Calendar.YEAR,
Calendar.MONTH, Calendar.MINUTE, etc.
DateModel.setTimeZone(TimeZone)
public void setUsed(int field,
boolean used)
DateModelSpecifies whether a certain field is used to construct the actual date
represented here. When the date is evaluated, all the fields that it
uses (marked with this method as used) must contain a value. Otherwise,
the date is considered incomplete and it is in fact a null date.
This method is mainly intended for use by date editing components that restrict the represented date only to some of its fields.
setUsed in interface DateModelfield - specified field that is marked as used or unusedused - true if the field is part of the date; false otherwiseDateModel.clear(int),
DateModel.getDate()public boolean isUsed(int field)
DateModel
isUsed in interface DateModelfield - field that is tested
true if the field is part of the date; false otherwiseDateModel.setUsed(int, boolean)public void setDate(java.util.Date date)
DateModelnull date will clear all the
basic fields like Calendar.YEAR, Calendar.MONTH,
Calendar.DATE, Calendar.HOUR, Calendar.MINUTE,
Calendar.SECOND and Calendar.MILLISECOND.
setDate in interface DateModeldate - date wrapped by the modelDateModel.clear(int)public java.util.Date getDate()
DateModelnull date is returned.
getDate in interface DateModelisDateValid()public void setAutoCentury(boolean auto)
DateModel
setAutoCentury in interface DateModelauto - true if century is automatically added;
false otherwiseDateModel.setAutoCenturyYear(int)public boolean isAutoCentury()
DateModel
isAutoCentury in interface DateModeltrue if century is automatically added;
false otherwise.DateModel.setAutoCentury(boolean)public void setAutoCenturyYear(int year)
DateModelSpecifies the year used to build the long year when short years are used. One can use short years which range from 0..99 when the autoCentury property is enabled. This means that instead of typing 1980 you can just use 80.
The short year is converted into a long year after it is compared with the last two digits of the autoCenturyYear year. Here are some examples that show how this mechanism works:
| short | autoCenturyYear | long |
|---|---|---|
| 30 | 1930 | 1930 |
| 56 | 1930 | 1956 |
| 11 | 1930 | 2011 |
setAutoCenturyYear in interface DateModelyear - reference year used to build the long year from a short oneDateModel.setAutoCentury(boolean)public int getAutoCenturyYear()
DateModel
getAutoCenturyYear in interface DateModelDateModel.setAutoCenturyYear(int)public boolean isDateValid()
All dates represented by this model are considered valid because invalid values are not allowed in the first place.
The only situation when invalid dates might occur is when entering a value for the day of month field because this field depends on the month and year. If these two fields are missing, then the value might be out of range.
For instance, if I first enter 31 for the day field, that's a valid valuesince there cannot be more than 31 days in a month. But if the month is February I cannot have more than 29 days. Even more, most of the time there are only 28 days and that depends on the year.
To fix this anomaly, when the date is built and the value from the day field is out of range, that value it is interpreted as the highest possible value. So Febrary 31, 2006 will be in fact Febrary 28, 2006.
isDateValid in interface DateModeltruepublic void addDateListener(DateListener listener)
DateModel
addDateListener in interface DateModellistener - listener to be registeredpublic void removeDateListener(DateListener listener)
DateModel
removeDateListener in interface DateModellistener - listener to be removedprotected void fireDateChanged(DateEvent evt)
protected void fireDateFieldChanged(DateEvent evt)
protected void fireDateFieldCleared(DateEvent evt)
|
JDatePicker v4.3 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Visit www.jdatepicker.com for further information or send us your suggestions.
Copyright © 2003-2007 Stand By Soft Ltd. All Rights Reserved.