org.apache.jackrabbit.rmi.value
Class DateValue

java.lang.Object
  extended byorg.apache.jackrabbit.rmi.value.BaseNonStreamValue
      extended byorg.apache.jackrabbit.rmi.value.DateValue
All Implemented Interfaces:
Serializable, StatefulValue, Value

public class DateValue
extends BaseNonStreamValue
implements 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

Constructor Summary
protected DateValue(Calendar value)
          Creates an instance for the given Calendar value.
protected DateValue(String value)
          Creates an instance for the given string representation of a Calendar.
 
Method Summary
 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 getLong()
          Returns the time represented by this instance as the number of milliseconds since the epoch (1.1.1970, 0:00, UTC).
 String getString()
          Returns the string represented of this Calendar value formatted using a SimpleDateFormatter with the pattern yyyy-MM-dd'T'HH:mm:ss'Z'.
 int getType()
          Returns PropertyType.DATE.
protected static Calendar toCalendar(String value)
          Returns the string value parsed into a Calendar instance.
 
Methods inherited from class org.apache.jackrabbit.rmi.value.BaseNonStreamValue
getBoolean, getStream, getValueFormatException
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.jcr.Value
getBoolean, getStream
 

Constructor Detail

DateValue

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


DateValue

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

This implementation uses a SimpleDateFormat instance with the pattern yyyy-MM-dd'T'HH:mm:ss'Z' to parse the string into a Calendar object. See the class comment for issues regarding this pattern.

Method Detail

toCalendar

protected static Calendar toCalendar(String value)
                              throws 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:
ValueFormatException - if the string value cannot be parsed into a Calendar instance.

getType

public int getType()
Returns PropertyType.DATE.

Specified by:
getType in interface 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 Value
Overrides:
getDouble in class BaseNonStreamValue
Returns:
nothing

getString

public String getString()
Returns the string represented of this Calendar value formatted using a SimpleDateFormatter with the pattern yyyy-MM-dd'T'HH:mm:ss'Z'. See the class comment for issues regarding this pattern.

Specified by:
getString in interface Value

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 Value
Overrides:
getLong in class BaseNonStreamValue
Returns:
nothing

getDate

public 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 Value
Overrides:
getDate in class BaseNonStreamValue
Returns:
nothing


Copyright © 2004-2006 . All Rights Reserved.