Version: 1.1.1

org.biomoby.shared.datatypes
Class MobyDateTime

java.lang.Object
  extended by org.biomoby.shared.datatypes.MobyObject
      extended by org.biomoby.shared.datatypes.MobyDateTime

public class MobyDateTime
extends MobyObject

An object representing a date, or a date and time, a Moby primitive data type.

The value of this object is stored internally as a string, but during setting it (setValue(java.lang.String)) it checks for its validity. The value should follow W3C profile of the ISO-8601 specification for specifying dates and times. For example (taken from the specification cited above), 1994-11-05T08:15:30-05:00 corresponds to November 5, 1994, 8:15:30 am, US Eastern Standard Time, and 1994-11-05T13:15:30Z corresponds to the same instant.

Version:
$Id: MobyDateTime.java,v 1.3 2007/05/21 00:56:15 senger Exp $
Author:
Martin Senger

Field Summary
static String[] ALLOWED_FORMATS
          An array defining all allowed formats for Biomoby DateTime objects.
static String FULL_FORMAT
          A string defining (in symbols used in Java's SimpleDateFormat) a full Biomoby DateTime format complying with ISO 8601.
 
Constructor Summary
MobyDateTime()
          Default constructor.
 
Method Summary
 void setValue(String value)
          Additionally to the same method in the superclass, it checks for a correct format.
 org.jdom.Element toXML()
          Create an XML element representing this object.
 
Methods inherited from class org.biomoby.shared.datatypes.MobyObject
addXref, format, getId, getMobyTypeName, getName, getNamespace, getProvision, getValue, getXrefs, isPrimitiveType, setId, setName, setNamespace, setProvision, setValueXML, setXrefs, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FULL_FORMAT

public static final String FULL_FORMAT
A string defining (in symbols used in Java's SimpleDateFormat) a full Biomoby DateTime format complying with ISO 8601.

See Also:
Constant Field Values

ALLOWED_FORMATS

public static final String[] ALLOWED_FORMATS
An array defining all allowed formats for Biomoby DateTime objects. Note that all formats are either full ISO 8601, or its subset, always starting from the left. Fo example, YYYY-MM is also a valid format because ISO 8601 starts with such string.

Constructor Detail

MobyDateTime

public MobyDateTime()
Default constructor.

Method Detail

toXML

public org.jdom.Element toXML()
Description copied from class: MobyObject
Create an XML element representing this object.

Overrides:
toXML in class MobyObject
Returns:
a jDom element that can be easily incorporated into a bigger XML document

setValue

public void setValue(String value)
              throws MobyException
Additionally to the same method in the superclass, it checks for a correct format.

It also allows values with the time zone in the format "+hhmm" and "-hhmm" (instead of correct ones "+hh:mm" and "-hh:mm"). Such values are the result of SimpleDateFormat constructor when fed with the FULL_FORMAT.

Overrides:
setValue in class MobyObject
Parameters:
value - to be stored; if it is null or an empty string it creates a date/time of the current moment

Throws:
MobyException - if the 'value' does not follow the ISO 8601 specification
See Also:
how to set value as CDATA

Version: 1.1.1

Submit a bug or feature
Generated: Sat May 29 04:26:35 EDT 2010