org.xins.common.types.standard
Class Timestamp

java.lang.Object
  extended byorg.xins.common.types.Type
      extended byorg.xins.common.types.standard.Timestamp

public class Timestamp
extends Type

Standard type _timestamp. A value of this type represents a certain moment in time, with second-precision, without an indication of the time zone.

The textual representation of a timestamp is always 14 numeric characters, in the format:

YYYYMMDDhhmmss
where:

Note that all timestamps will be based on the current time zone (see TimeZone.getDefault()).

A number of milliseconds can be used to indicate a specific instant in time. This number of milliseconds is since the UNIX Epoch.

Since:
XINS 1.0.0
Version:
$Revision: 1.28 $ $Date: 2006/08/28 09:12:33 $
Author:
Anthony Goubard, Ernst de Haan

Nested Class Summary
static class Timestamp.Value
          Value for the type _timestamp.
 
Field Summary
static Timestamp SINGLETON
          The only instance of this class.
 
Method Summary
static Timestamp.Value fromStringForOptional(String string)
          Constructs a Timestamp.Value from the specified string.
static Timestamp.Value fromStringForRequired(String string)
          Constructs a Timestamp.Value from the specified non-null string.
protected  Object fromStringImpl(String string)
          Converts from a String to an instance of the value class for this type (implementation method).
protected  boolean isValidValueImpl(String value)
          Determines if the specified String value is considered valid for this type (implementation method).
static Timestamp.Value now()
          Constructs a Timestamp.Value with the value of the current time.
 String toString(Object value)
          Generates a string representation of the specified value for this type.
static String toString(Timestamp.Value value)
          Converts the specified Timestamp.Value to a string.
 
Methods inherited from class org.xins.common.types.Type
checkValue, fromString, getName, getValueClass, isValidValue, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SINGLETON

public static final Timestamp SINGLETON
The only instance of this class. This field is never null.

Method Detail

now

public static Timestamp.Value now()
Constructs a Timestamp.Value with the value of the current time.

Returns:
the Timestamp.Value initialized with the current time, never null.

fromStringForRequired

public static Timestamp.Value fromStringForRequired(String string)
                                             throws IllegalArgumentException,
                                                    TypeValueException
Constructs a Timestamp.Value from the specified non-null string.

Parameters:
string - the string to convert, cannot be null.
Returns:
the Timestamp.Value object, never null.
Throws:
IllegalArgumentException - if string == null.
TypeValueException - if the specified string does not represent a valid value for this type.

fromStringForOptional

public static Timestamp.Value fromStringForOptional(String string)
                                             throws TypeValueException
Constructs a Timestamp.Value from the specified string.

Parameters:
string - the string to convert, can be null.
Returns:
the Timestamp.Value, or null if string == null.
Throws:
TypeValueException - if the specified string does not represent a valid value for this type.

toString

public static String toString(Timestamp.Value value)
Converts the specified Timestamp.Value to a string.

Parameters:
value - the value to convert, can be null.
Returns:
the textual representation of the value; or null if and only if value == null.

isValidValueImpl

protected final boolean isValidValueImpl(String value)
Description copied from class: Type
Determines if the specified String value is considered valid for this type (implementation method).

This method is called from Type.isValidValue(String). When called from that method, it is guaranteed that the argument is not null.

The implementation of this method in class Type returns true.

Overrides:
isValidValueImpl in class Type
Parameters:
value - the String value that should be checked for validity, never null.
Returns:
true if and only if the specified String value is valid, false otherwise.

fromStringImpl

protected final Object fromStringImpl(String string)
                               throws TypeValueException
Description copied from class: Type
Converts from a String to an instance of the value class for this type (implementation method).

This method is not required to check the validity of the specified value (since Type.isValidValueImpl(String) should have been called before) but if it does, then it may throw a TypeValueException.

Specified by:
fromStringImpl in class Type
Parameters:
string - the string to convert to an instance of the value class, guaranteed to be not null and guaranteed to have been passed to Type.isValidValueImpl(String) without getting an exception.
Returns:
an instance of the value class, cannot be null.
Throws:
TypeValueException - if string is considered to be an invalid value for this type.

toString

public final String toString(Object value)
                      throws IllegalArgumentException,
                             ClassCastException,
                             TypeValueException
Description copied from class: Type
Generates a string representation of the specified value for this type. The specified value must be an instance of the value class for this type (see Type.getValueClass()). Also, it may have to fall within a certain range of valid values, depending on the type.

The default implementation of this method in class Type does the following:

Overrides:
toString in class Type
Parameters:
value - the value, cannot be null.
Returns:
the string representation of the specified value for this type, cannot be null.
Throws:
ClassCastException - if getValueClass().isInstance(value) == false.
IllegalArgumentException - if value == null.
TypeValueException - if the specified value is not in the allowed range.


See http://www.xins.org/.