org.mmbase.datatypes
Class DateTimeDataType

java.lang.Object
  extended by org.mmbase.core.AbstractDescriptor
      extended by org.mmbase.datatypes.BasicDataType<E>
          extended by org.mmbase.datatypes.ComparableDataType<Date>
              extended by org.mmbase.datatypes.DateTimeDataType
All Implemented Interfaces:
Serializable, Cloneable, Comparable<DataType<Date>>, Descriptor, DataType<Date>, PublicCloneable<AbstractDescriptor>

public class DateTimeDataType
extends ComparableDataType<Date>

The date-time datatype further describes Date objects. The date can be restricted to a certain period (using ComparableDataType.setMin(E, boolean), ComparableDataType.setMax(E, boolean), and Casting.toDate(java.lang.Object). The presentation logic can be specified using a pattern, see getPattern().

Since:
MMBase-1.8
Version:
$Id: DateTimeDataType.java 42197 2010-05-17 14:00:50Z michiel $
Author:
Pierre van Rooden, Michiel Meeuwissen
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.mmbase.datatypes.ComparableDataType
ComparableDataType.MaxRestriction, ComparableDataType.MinRestriction
 
Nested classes/interfaces inherited from class org.mmbase.datatypes.BasicDataType
BasicDataType.AbstractRestriction<D extends Serializable>, BasicDataType.DataTypeComparator<D>, BasicDataType.EnumerationRestriction, BasicDataType.RequiredRestriction, BasicDataType.RestrictedEnumerationIterator, BasicDataType.StaticAbstractRestriction<D extends Serializable>, BasicDataType.TypeRestriction, BasicDataType.UniqueRestriction
 
Nested classes/interfaces inherited from interface org.mmbase.datatypes.DataType
DataType.Restriction<D extends Serializable>
 
Field Summary
static Date MAX_VALUE
           
static Date MIN_VALUE
           
 
Fields inherited from class org.mmbase.datatypes.ComparableDataType
maxRestriction, minRestriction
 
Fields inherited from class org.mmbase.datatypes.BasicDataType
DATATYPE_BUNDLE, defaultValue, enumerationRestriction, origin, requiredRestriction, typeRestriction, uniqueRestriction
 
Fields inherited from class org.mmbase.core.AbstractDescriptor
description, guiName, key
 
Fields inherited from interface org.mmbase.datatypes.DataType
ENFORCE_ABSOLUTE, ENFORCE_ALWAYS, ENFORCE_NEVER, ENFORCE_ONCHANGE, ENFORCE_ONCREATE, ENFORCE_ONVALIDATE, PROCESS_GET, PROCESS_SET, VALID, XMLNS
 
Constructor Summary
DateTimeDataType(String name)
          Constructor for DateTime field.
 
Method Summary
protected  Object castToValidate(Object value, Node node, Field field)
          Before validating the value, the value will be 'cast', on default this will be to the 'correct' type, but it can be a more generic type sometimes.
 DateTimeDataType clone(String name)
          Returns a cloned instance of this datatype, inheriting all validation rules.
 Date first()
          Returns a natural 'first' value.
 Date getMax()
           
 Date getMin()
           
 DateTimePattern getPattern()
          The 'pattern' of a 'DateTime' value gives a DateTimePattern object which can be used as an indication for presentation.
 TimeZone getTimeZone()
          A timezone can be attributed.
protected  void inheritProperties(BasicDataType origin)
          Properties are members of the datatype that can easily be copied/clones.
 void setDefaultValue(Object o)
          Set the default value for this DataType
 void setPattern(String p, Locale locale)
          Set the pattern for a certain Locale.
 void setTimeZone(TimeZone tz)
          You can assign a time zone to the datatype.
protected  StringBuilder toStringBuilder()
           
protected  void xmlValue(Element el, Object value)
           
 
Methods inherited from class org.mmbase.datatypes.ComparableDataType
cloneRestrictions, compare, getComparator, getDefaultValue, getEnforceStrength, getMaxRestriction, getMinRestriction, inheritRestrictions, isMaxInclusive, isMinInclusive, setMax, setMin, toXml, validateCastValue
 
Methods inherited from class org.mmbase.datatypes.BasicDataType
addErrorDescription, addRestriction, addRestriction, addStyleClass, cast, cast, castAndValidate, castForSearch, castOrException, castToPresent, checkType, clone, compareTo, edit, equals, finish, finish, getBaseType, getBaseTypeIdentifier, getCloud, getCloud, getCommitProcessor, getDefaultProcessor, getDefaultValue, getDeleteProcessor, getElement, getElement, getEnforceString, getEnumerationFactory, getEnumerationRestriction, getEnumerationValue, getEnumerationValues, getHandler, getHandlers, getOrigin, getProcessor, getProcessor, getProcessorWithoutDefault, getRequiredRestriction, getRestrictions, getStyleClasses, getTypeAsClass, getUniqueRestriction, hashCode, inherit, isCorrectType, isFinished, isRequired, isUnique, preCast, preCast, preCast, rewrite, setCommitProcessor, setDefaultProcessor, setDeleteProcessor, setProcessor, setProcessor, setRequired, setUnique, setXml, toString, toXml, validate, validate, validateCastValueOrNull, validateRequired
 
Methods inherited from class org.mmbase.core.AbstractDescriptor
getDefaultLocale, getDescription, getDescription, getGUIName, getGUIName, getLocalizedDescription, getLocalizedGUIName, getName, setDescription, setDescription, setGUIName, setGUIName, setLocalizedDescription, setLocalizedGUIName
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mmbase.bridge.Descriptor
getDescription, getDescription, getGUIName, getGUIName, getLocalizedDescription, getLocalizedGUIName, getName, setDescription, setDescription, setGUIName, setGUIName
 

Field Detail

MIN_VALUE

public static final Date MIN_VALUE

MAX_VALUE

public static final Date MAX_VALUE
Constructor Detail

DateTimeDataType

public DateTimeDataType(String name)
Constructor for DateTime field.

Method Detail

xmlValue

protected void xmlValue(Element el,
                        Object value)
Overrides:
xmlValue in class BasicDataType<Date>

setDefaultValue

public void setDefaultValue(Object o)
Description copied from class: BasicDataType
Set the default value for this DataType

Specified by:
setDefaultValue in interface DataType<Date>
Overrides:
setDefaultValue in class BasicDataType<Date>
Parameters:
o - default value

inheritProperties

protected void inheritProperties(BasicDataType origin)
Description copied from class: BasicDataType
Properties are members of the datatype that can easily be copied/clones.

Overrides:
inheritProperties in class BasicDataType<Date>

castToValidate

protected Object castToValidate(Object value,
                                Node node,
                                Field field)
                         throws CastException
Description copied from class: BasicDataType
Before validating the value, the value will be 'cast', on default this will be to the 'correct' type, but it can be a more generic type sometimes. E.g. for numbers this wil simply cast to Number.

Overrides:
castToValidate in class BasicDataType<Date>
Throws:
CastException

getMin

public Date getMin()
Returns:
the minimum value as an Date, or very very long ago if there is no minimum.

getMax

public Date getMax()
Returns:
the maximum value as an Date, or a date very very far in the future if there is no maximum.

getPattern

public DateTimePattern getPattern()
The 'pattern' of a 'DateTime' value gives a DateTimePattern object which can be used as an indication for presentation. Basicly, this can indicate whether the objects present e.g. only a date, only a time and whether e.g. this time includes seconds or not. DateTimePattern is actually a wrapper arround a pattern, and that is used here.


setPattern

public void setPattern(String p,
                       Locale locale)
Set the pattern for a certain Locale. See also getPattern().


setTimeZone

public void setTimeZone(TimeZone tz)
You can assign a time zone to the datatype. This only has effect on getTimeZone(). Normally the timezone is provided by the client, but sometimes the timezone can be an intrinsic part of the datatype.

Since:
MMBase-1.9.4

getTimeZone

public TimeZone getTimeZone()
A timezone can be attributed.

Returns:
A TimeZone or null (default)
Since:
MMBase-1.9.4

clone

public DateTimeDataType clone(String name)
Description copied from class: BasicDataType
Returns a cloned instance of this datatype, inheriting all validation rules. Similar to calling clone(), but changes the data type name if one is provided. Besides super.clone, it calls BasicDataType.inheritProperties(BasicDataType) and BasicDataType.cloneRestrictions(BasicDataType). A clone is not finished. See BasicDataType.isFinished().

Specified by:
clone in interface DataType<Date>
Overrides:
clone in class ComparableDataType<Date>
Parameters:
name - the new name of the copied datatype (can be null, in which case the name is not changed).
Returns:
cloned DataType

toStringBuilder

protected StringBuilder toStringBuilder()
Overrides:
toStringBuilder in class ComparableDataType<Date>

first

public Date first()
Description copied from class: ComparableDataType
Returns a natural 'first' value. This may return some kind of 0

Specified by:
first in class ComparableDataType<Date>


MMBase 2.0-SNAPSHOT - null