org.beanfabrics.model
Class DatePM
java.lang.Object
org.beanfabrics.AbstractBean
org.beanfabrics.ValidatableBean
org.beanfabrics.model.AbstractPM
org.beanfabrics.model.AbstractValuePM
org.beanfabrics.model.TextPM
org.beanfabrics.model.DatePM
- All Implemented Interfaces:
- Bean, ContextOwner, IDatePM, ITextPM, IValuePM, PresentationModel, Supportable, Validatable
public class DatePM
- extends TextPM
- implements IDatePM
The DatePM is a presentation model for Date objects. The text format
is locale dependent but can be changed manually by calling
setFormat(DateFormat).
- Author:
- Max Gensthaler, Michael Karneim
|
Constructor Summary |
DatePM()
Constructs a new instance with the default format (just showing the date,
not the time). |
|
Method Summary |
protected java.text.DateFormat |
createDefaultFormat()
This returns a localized DateFormat for converting a Date
to a String and vice versa. |
java.lang.Comparable |
getComparable()
|
java.util.Date |
getDate()
Return the date represented by this object. |
static java.text.DateFormat |
getDateFormat(java.util.Locale locale)
|
java.text.DateFormat |
getFormat()
Return the format to be used by this object to check the input and
convert the input to a Date and vice versa. |
void |
setDate(java.util.Date date)
Set the Date to be represented by this object. |
void |
setDefaultDate(java.util.Date date)
|
void |
setFormat(java.text.DateFormat newFormat)
Set the format to be used by this object to check the input and convert
the input to a Date and vice versa. |
| Methods inherited from class org.beanfabrics.model.TextPM |
getDefaultText, getOptions, getText, getText, isEmpty, isModified, isRestrictedToOptions, preset, reformat, reset, setDefaultText, setOptions, setRestrictedToOptions, setText, toString |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
KEY_MESSAGE_INVALID_DATE
protected static final java.lang.String KEY_MESSAGE_INVALID_DATE
- See Also:
- Constant Field Values
DatePM
public DatePM()
- Constructs a new instance with the default format (just showing the date,
not the time).
getFormat
public java.text.DateFormat getFormat()
- Return the format to be used by this object to check the input and
convert the input to a
Date and vice versa.
- Specified by:
getFormat in interface IDatePM
setFormat
public void setFormat(java.text.DateFormat newFormat)
- Set the format to be used by this object to check the input and convert
the input to a
Date and vice versa.
I.e. to set a format showing date and time do:
DateFormat format = DateFormat.getDateTimeInstance();
format.setLenient(false);
setFormat(format);
- Specified by:
setFormat in interface IDatePM
- Parameters:
newFormat - format to use for Date-String conversion
createDefaultFormat
protected java.text.DateFormat createDefaultFormat()
- This returns a localized
DateFormat for converting a Date
to a String and vice versa.
getDate
public java.util.Date getDate()
throws ConversionException
- Return the date represented by this object.
- Specified by:
getDate in interface IDatePM
- Throws:
ConversionException - thrown if the text of this object cannot be
parsed as date by the given format
setDate
public void setDate(java.util.Date date)
- Set the
Date to be represented by this object.
- Specified by:
setDate in interface IDatePM
- Parameters:
date - Date to set
setDefaultDate
public void setDefaultDate(java.util.Date date)
getComparable
public java.lang.Comparable getComparable()
- Specified by:
getComparable in interface IValuePM- Overrides:
getComparable in class TextPM
getDateFormat
public static java.text.DateFormat getDateFormat(java.util.Locale locale)
© 2010 by Michael Karneim, http://www.beanfabrics.org