Java Date Picker v3.2

com.standbysoft.component.date
Class DefaultDateModel

java.lang.Object
  extended bycom.standbysoft.component.date.DefaultDateModel
All Implemented Interfaces:
DateModel

public class DefaultDateModel
extends java.lang.Object
implements DateModel

A default implementation for a date model.


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.
 boolean isAutoCentury()
          Determines whether century is automatically added to the year field if its value is less than 100.
 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 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
 

Constructor Detail

DefaultDateModel

public DefaultDateModel()
Creates a date model that represents the current system date. Auto century is enabled.

Method Detail

isSet

public boolean isSet(int field)
Description copied from interface: DateModel
Determines whether a specified field is cleared or not.

Specified by:
isSet in interface DateModel
Parameters:
field - field that is tested. Possible values are: Calendar.YEAR, Calendar.MONTH, Calendar.MINUTE, etc.
Returns:
true if the field is not cleared; false otherwise
See Also:
DateModel.clear(int)

clear

public void clear(int field)
Description copied from interface: DateModel
Clears a specified field, meaning that it contains no value.

Specified by:
clear in interface DateModel
Parameters:
field - field that is cleared. Possible values are: Calendar.YEAR, Calendar.MONTH, Calendar.MINUTE, etc.
See Also:
DateModel.isSet(int)

set

public void set(int field,
                int val)
Description copied from interface: DateModel
Modifies the value of a specified date field.

Specified by:
set in interface DateModel
Parameters:
field - 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.

get

public int get(int field)
Description copied from interface: DateModel
Returns the value of a specified field.

Specified by:
get in interface DateModel
Parameters:
field - date field that is tested. Possible values are: Calendar.YEAR, Calendar.MONTH, Calendar.MINUTE, etc.
Returns:
value of the specified field.

setUsed

public void setUsed(int field,
                    boolean used)
Description copied from interface: DateModel

Specifies 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.

Specified by:
setUsed in interface DateModel
Parameters:
field - specified field that is marked as used or unused
used - true if the field is part of the date; false otherwise
See Also:
DateModel.clear(int), DateModel.getDate()

isUsed

public boolean isUsed(int field)
Description copied from interface: DateModel
Determines whether a specified field is part of the date.

Specified by:
isUsed in interface DateModel
Parameters:
field - field that is tested
Returns:
true if the field is part of the date; false otherwise
See Also:
DateModel.setUsed(int, boolean)

setDate

public void setDate(java.util.Date date)
Description copied from interface: DateModel
Specifies a new date to be represented by this model that can later be modified field by field. A null date will clear all the basic fields like Calendar.YEAR, Calendar.MONTH, Calendar.DATE, Calendar.HOUR, Calendar.MINUTE, Calendar.SECOND and Calendar.MILLISECOND.

Specified by:
setDate in interface DateModel
Parameters:
date - date wrapped by the model
See Also:
DateModel.clear(int)

getDate

public java.util.Date getDate()
Description copied from interface: DateModel
Returns the date wrapped by this model. If there are missing fields and the date cannot be computed then a null date is returned.

Specified by:
getDate in interface DateModel
Returns:
date wrapped by this model.
See Also:
DateModel.setDate(Date), DateModel.isSet(int)

setAutoCentury

public void setAutoCentury(boolean auto)
Description copied from interface: DateModel
Specifies whether century is automatically added to the year field if its value is less than 100.

Specified by:
setAutoCentury in interface DateModel
Parameters:
auto - true if century is automatically added; false otherwise
See Also:
DateModel.setAutoCenturyYear(int)

isAutoCentury

public boolean isAutoCentury()
Description copied from interface: DateModel
Determines whether century is automatically added to the year field if its value is less than 100.

Specified by:
isAutoCentury in interface DateModel
Returns:
true if century is automatically added; false otherwise.
See Also:
DateModel.setAutoCentury(boolean)

setAutoCenturyYear

public void setAutoCenturyYear(int year)
Description copied from interface: DateModel

Specifies 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:

shortautoCenturyYearlong
3019301930
5619301956
1119302011

Specified by:
setAutoCenturyYear in interface DateModel
Parameters:
year - reference year used to build the long year from a short one
See Also:
DateModel.setAutoCentury(boolean)

getAutoCenturyYear

public int getAutoCenturyYear()
Description copied from interface: DateModel
Determines the reference year used to build the long year from a short one. By default, this year is 1930.

Specified by:
getAutoCenturyYear in interface DateModel
Returns:
reference year used to build the long year from a short one.
See Also:
DateModel.setAutoCenturyYear(int)

addDateListener

public void addDateListener(DateListener listener)
Description copied from interface: DateModel
Registers a new date listener to the model.

Specified by:
addDateListener in interface DateModel
Parameters:
listener - listener to be registered

removeDateListener

public void removeDateListener(DateListener listener)
Description copied from interface: DateModel
Removes a specified date listener from this model.

Specified by:
removeDateListener in interface DateModel
Parameters:
listener - listener to be removed

fireDateChanged

protected void fireDateChanged(DateEvent evt)

fireDateFieldChanged

protected void fireDateFieldChanged(DateEvent evt)

fireDateFieldCleared

protected void fireDateFieldCleared(DateEvent evt)

Java Date Picker v3.2

Visit www.javadatepicker.com for further information or send us your suggestions.

Copyright © 2003-2004 Stand By Soft Ltd. All Rights Reserved.