TimePeriod Class

com.bea.p13n.xml.schema
TimePeriod Class

public class TimePeriod

    extends Object
    implements Cloneable, Comparable, Serializable

This class provides the Java biding for the XML schema type timePeriod as specified in Section 3.3.26 of XML Schema Part 2: Datatypes.

timePeriod represents a specific period of time with a given start and end.

The value of an instance of timePeriod specifies the start of the time period, while the value of dudation should be specified in the schema.

Example: 09:00:00.000Z.

Instance of this type can be constructed from instances of TimeInstant and TimePeriod.

NOTE:

This is special case where a facet (the duration facet) should be specified while creating an instance of TimePeriod. Without this information, an instance of TimePeriod would be meaningless.


Hierarchy
Object
  TimePeriod
All Implemented Interfaces

Cloneable, Comparable, Serializable

Constructor Summary

TimePeriod()

Constructs a new TimePeriod instance with "P0Y" as the duration and period at the current point in time.
 

Method Summary

public Object
clone()
Returns a copy of this TimeDuration.
public int
compareTo(TimePeriod anotherTimePeriod)

Compares this TimePeriod to another TimePeriod object (represented in the same time zone) in their canonical representation.

public int
compareTo(Object anotherObject)
Compares this TimePeriod with another object.
public static TimePeriod
createTimePeriod()
Returns a TimePeriod instance for the current time at the local time zone with zero duration.
public static TimePeriod
createTimePeriod(String start, String duration)
Given the start time instant and duration, returns a TimePeriod instance.
public static TimePeriod
createTimePeriod(TimeInstant start, TimeDuration duration)
Given the start time instant and duration, returns a TimePeriod instance.
public TimeDuration
getDuration()
Returns the duration for this TimePeriod.
public TimeInstant
getEnd()
Returns the end of this duration based on the current values of start time instannt and duration.
public TimeInstant
getStart()
Returns the instant at which this TimePeriod starts.
public void
setDuration(TimeDuration duration)
Sets the duration for this TimePeriod.
public void
setStart(TimeInstant start)
Sets the instant at which this TimePeriod starts.
public String
toString()

Returns a XML schema compliant timePeriod string.

 
Methods from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
   
Methods from interface java.lang.Comparable
compareTo
 

Constructor Detail

TimePeriod

protected TimePeriod()
Constructs a new TimePeriod instance with "P0Y" as the duration and period at the current point in time.
 

Method Detail

clone() Method

public Object clone()
Returns a copy of this TimeDuration.

Overrides
Object.clone()

Returns

copy

compareTo(TimePeriod) Method

public int compareTo(TimePeriod anotherTimePeriod)

Compares this TimePeriod to another TimePeriod object (represented in the same time zone) in their canonical representation. Two time periods are considered to be equal if both the start time instant and duration are equal.

Two instances of time periods can be compared only when both time periods start at the same time instant.

Parameters

anotherTimePeriod
another TimePeriod object to be compared.

Returns

the value 0 if the argument TimePeriod is equal to this TimePeriod; a value less than 0 if this TimePeriod is before the TimePeriod argument; and a value greater than 0 if this TimePeriod is after the TimePeriod argument.

compareTo(Object) Method

public int compareTo(Object anotherObject)
Compares this TimePeriod with another object. If the other object is a TimePeriod, this method behaves like compareTo(TimePeriod). Otherwise, it throws a ClassCastException.

Parameters

anotherObject
the object to be compared

Returns

the value 0 if the argument TimePeriod is equal to this TimePeriod; a value less than 0 if this TimePeriod is before the TimePeriod argument; and a value greater than 0 if this TimePeriod is after the TimePeriod argument.

createTimePeriod() Method

public static TimePeriod createTimePeriod()
Returns a TimePeriod instance for the current time at the local time zone with zero duration.

Returns

instance of TimeDuratio

createTimePeriod(String, String) Method

public static TimePeriod createTimePeriod(String start, 
                                          String duration)
throws ParseException
Given the start time instant and duration, returns a TimePeriod instance.

Parameters

start
start time instant
duration
duration

Returns

instance of TimePeriod

Exceptions

ParseException

createTimePeriod(TimeInstant, TimeDuration) Method

public static TimePeriod createTimePeriod(TimeInstant start, 
                                          TimeDuration duration)
Given the start time instant and duration, returns a TimePeriod instance.

Parameters

start
start time instant
duration
duration

Returns

instance of TimePeriod

getDuration() Method

public TimeDuration getDuration()
Returns the duration for this TimePeriod.

Returns

duration of this time period

getEnd() Method

public TimeInstant getEnd()
Returns the end of this duration based on the current values of start time instannt and duration.

Returns

end time instant for this time period

getStart() Method

public TimeInstant getStart()
Returns the instant at which this TimePeriod starts.

Returns

start of this time period

setDuration(TimeDuration) Method

public void setDuration(TimeDuration duration)
Sets the duration for this TimePeriod.

Parameters

duration
duration

setStart(TimeInstant) Method

public void setStart(TimeInstant start)
Sets the instant at which this TimePeriod starts.

Parameters

start
starting instant

toString() Method

public String toString()

Returns a XML schema compliant timePeriod string.

Overrides
Object.toString()

Returns

string value