org.exoplatform.services.jcr.rmi.api.value
Class DateValue

java.lang.Object
  extended by org.exoplatform.services.jcr.rmi.api.value.BaseNonStreamValue
      extended by org.exoplatform.services.jcr.rmi.api.value.DateValue
All Implemented Interfaces:
java.io.Serializable, javax.jcr.Value, ExtendedValue, StatefulValue

public class DateValue
extends BaseNonStreamValue
implements java.io.Serializable, StatefulValue

The DateValue class implements the committed value state for Date values as a part of the State design pattern (Gof) used by this package.

To convert Calendar instances to and from strings, this class uses a SimpleDateFormat instance with the pattern yyyy-MM-dd'T'HH:mm:ss'Z'. The issue with this pattern is that the era specification as defined in the JCR specification (+/- prefix) as well as full time zone naming are not supported.

Since:
0.16.4.1
See Also:
SerialValue, Serialized Form

Field Summary
 
Fields inherited from class org.exoplatform.services.jcr.rmi.api.value.BaseNonStreamValue
orderNumber
 
Constructor Summary
protected DateValue(java.util.Calendar value)
          Creates an instance for the given Calendar value.
protected DateValue(java.lang.String value)
          Creates an instance for the given string representation of a Calendar.
 
Method Summary
 java.util.Calendar getDate()
          Returns (a copy) of this Calendar value.
 double getDouble()
          Returns the time represented by this instance as the number of milliseconds since the epoch (1.1.1970, 0:00, UTC).
 long getLength()
           
 long getLong()
          Returns the time represented by this instance as the number of milliseconds since the epoch (1.1.1970, 0:00, UTC).
 int getOrderNumber()
           
 java.lang.String getString()
          Returns the string represented of this Calendar value formatted using a ISO8601.format with the pattern YYYY-MM-DDThh:mm:ss.sssTZD.
 int getType()
          Returns PropertyType.DATE.
protected static java.util.Calendar toCalendar(java.lang.String value)
          Returns the string value parsed into a Calendar instance.
 
Methods inherited from class org.exoplatform.services.jcr.rmi.api.value.BaseNonStreamValue
getBoolean, getReference, getStream, getValueFormatException, setOrderNumber
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.exoplatform.services.jcr.core.value.ExtendedValue
getReference, setOrderNumber
 
Methods inherited from interface javax.jcr.Value
getBoolean, getStream
 

Constructor Detail

DateValue

protected DateValue(java.util.Calendar value)
Creates an instance for the given Calendar value.


DateValue

protected DateValue(java.lang.String value)
             throws javax.jcr.ValueFormatException
Creates an instance for the given string representation of a Calendar.

This implementation uses a ISO8601.format instance with the pattern YYYY-MM-DDThh:mm:ss.sssTZD to parse the string into a Calendar object. See the class comment for issues regarding this pattern.

Throws:
javax.jcr.ValueFormatException
Method Detail

toCalendar

protected static java.util.Calendar toCalendar(java.lang.String value)
                                        throws javax.jcr.ValueFormatException
Returns the string value parsed into a Calendar instance.

Parameters:
value - The string value.
Returns:
The Calendar instance parsed from the string value.
Throws:
javax.jcr.ValueFormatException - if the string value cannot be parsed into a Calendar instance.

getType

public int getType()
Returns PropertyType.DATE.

Specified by:
getType in interface javax.jcr.Value

getDouble

public double getDouble()
Returns the time represented by this instance as the number of milliseconds since the epoch (1.1.1970, 0:00, UTC).

Specified by:
getDouble in interface javax.jcr.Value
Overrides:
getDouble in class BaseNonStreamValue
Returns:
nothing

getString

public java.lang.String getString()
                           throws javax.jcr.ValueFormatException
Returns the string represented of this Calendar value formatted using a ISO8601.format with the pattern YYYY-MM-DDThh:mm:ss.sssTZD. See the class comment for issues regarding this pattern.

Specified by:
getString in interface javax.jcr.Value
Throws:
javax.jcr.ValueFormatException

getLong

public long getLong()
Returns the time represented by this instance as the number of milliseconds since the epoch (1.1.1970, 0:00, UTC).

Specified by:
getLong in interface javax.jcr.Value
Overrides:
getLong in class BaseNonStreamValue
Returns:
nothing

getDate

public java.util.Calendar getDate()
Returns (a copy) of this Calendar value. Modifying the returned Calendar does not change the value of this instance.

Specified by:
getDate in interface javax.jcr.Value
Overrides:
getDate in class BaseNonStreamValue
Returns:
nothing

getLength

public long getLength()
Specified by:
getLength in interface ExtendedValue

getOrderNumber

public int getOrderNumber()
Specified by:
getOrderNumber in interface ExtendedValue
Overrides:
getOrderNumber in class BaseNonStreamValue


Copyright © 2010 eXo Platform SAS. All Rights Reserved.