Venice 0.7beta

org.mov.util
Class TradingTime

java.lang.Object
  extended by org.mov.util.TradingTime
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable

public class TradingTime
extends java.lang.Object
implements java.lang.Cloneable, java.lang.Comparable

A replacement time for java.util.Calendar. The main principles of this time class are speed (as fast as possible) and size (as small as possible). It produces a much smaller and faster time class than using the Calendar hierarchy.

Author:
Andrew Leppard

Field Summary
static int HOURS_IN_DAY
          Number of hours in one day.
static int MILLISECONDS_IN_SECOND
          Number of milliseconds in one second.
static int MINUTES_IN_HOUR
          Number of minutes in one hour.
static int SECONDS_IN_MINUTE
          Number of seconds in one minute.
 
Constructor Summary
TradingTime()
          Create a new time set to now.
TradingTime(int hour, int minute, int second)
          Create a new time from the given hour, minute and second.
TradingTime(java.lang.String time)
           
 
Method Summary
 boolean after(java.lang.Object time)
          Tests if this time is after the specified time.
 boolean before(java.lang.Object time)
          Tests if this time is before the specified time.
 java.lang.Object clone()
           
 int compareTo(java.lang.Object time)
          Compare the current time to the specified object.
 int compareTo(TradingTime time)
          Compare the current time to the specified time.
 boolean equals(java.lang.Object time)
          Compares this time with the specified object.
 int getHour()
          Return the hour.
 int getMinute()
          Return the minute.
 int getSecond()
          Return the second.
 java.lang.String toString()
          Returns a string version of the time.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

HOURS_IN_DAY

public static final int HOURS_IN_DAY
Number of hours in one day.

See Also:
Constant Field Values

MINUTES_IN_HOUR

public static final int MINUTES_IN_HOUR
Number of minutes in one hour.

See Also:
Constant Field Values

SECONDS_IN_MINUTE

public static final int SECONDS_IN_MINUTE
Number of seconds in one minute.

See Also:
Constant Field Values

MILLISECONDS_IN_SECOND

public static final int MILLISECONDS_IN_SECOND
Number of milliseconds in one second.

See Also:
Constant Field Values
Constructor Detail

TradingTime

public TradingTime(int hour,
                   int minute,
                   int second)
Create a new time from the given hour, minute and second.

Parameters:
hour - the hour from 0 to 23.
minute - the minute from 0 to 59.
second - the second from 0 to 62 (leap seconds).

TradingTime

public TradingTime()
Create a new time set to now.


TradingTime

public TradingTime(java.lang.String time)
            throws TradingTimeFormatException
Throws:
TradingTimeFormatException
Method Detail

before

public boolean before(java.lang.Object time)
Tests if this time is before the specified time.

Parameters:
time - the specified time to compare
Returns:
true if the given time is before this one

after

public boolean after(java.lang.Object time)
Tests if this time is after the specified time.

Parameters:
time - the specified time to compare
Returns:
true if the specified time is before this one; false otherwise.

equals

public boolean equals(java.lang.Object time)
Compares this time with the specified object.

Overrides:
equals in class java.lang.Object
Parameters:
time - the specified time to compare
Returns:
true if the specified time is equal; false otherwise.

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

compareTo

public int compareTo(java.lang.Object time)
Compare the current time to the specified object.

Specified by:
compareTo in interface java.lang.Comparable
See Also:
compareTo(TradingTime)

compareTo

public int compareTo(TradingTime time)
Compare the current time to the specified time.

Parameters:
time - the time to compare
Returns:
the value 0 if the times are equal; 1 if this time is after the specified time or -1 if this time is before the specified time.

getHour

public int getHour()
Return the hour.

Returns:
the hour staring from 0.

getMinute

public int getMinute()
Return the minute.

Returns:
the minute staring from 0.

getSecond

public int getSecond()
Return the second.

Returns:
the second staring from 0.

toString

public java.lang.String toString()
Returns a string version of the time.

Overrides:
toString in class java.lang.Object
Returns:
string version

Venice 0.7beta