com.fxcm.fix
Class UTCTimestamp

java.lang.Object
  extended by com.fxcm.fix.UTCTimestamp
All Implemented Interfaces:
Serializable, Comparable
Direct Known Subclasses:
UTCDate, UTCTimeOnly

public class UTCTimestamp
extends Object
implements Comparable, Serializable

UTCTimestamp handles UTC timestamp functionality. Time/date combination represented in UTC (Universal Time Coordinated, also known as "GMT")

See Also:
Serialized Form

Constructor Summary
UTCTimestamp()
          Constructor via current UTC date.
UTCTimestamp(Date aID)
          Constructor via given date object.
UTCTimestamp(String aTime)
          Constructor via given date time string of UTC time.
UTCTimestamp(UTCTimestamp aTimestamp)
          Constructor via given UTC timestamp (copy constructor).
UTCTimestamp(UTCTimestamp aDate, UTCTimestamp aTime)
          Constructor via given UTC date and time (combine constructor).
 
Method Summary
 UTCTimestamp addDuration(long aMsec)
          Rolls up or down the timestamp value.
 int compareTo(Object aObj)
          Compares this object with the specified object for order.
 boolean equals(Object aObj)
          Indicates whether some other object is "equal to" this one.
 Date getLocalDate()
          Deprecated. Date object has no dependency on TimeZone.
static int getLocalTimeZone()
          Deprecated. use java.util.Calendar aproach.
 long getTime()
          Obtains the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this object.
 void setDate(Date aTime)
          Updates timestamp
 void setLocalDate(Date aLocalTime)
          Deprecated. Date object has no dependency on TimeZone.
 Date toDate()
          Converts timestamp to date object.
 Date toDate(int aTimeZone)
          Deprecated. Date object has no dependency on TimeZone.
 Date toDateRef()
          Deprecated. There is no anymore such thing as internal Data object inside.
 String toString()
          Converts timestamp to string with UTC time.
 String toString(int aTimeZone)
          Deprecated. use java.text.SimpleDateFormat approach
 String toStringMs()
          Temporary: Converts timestamp to string with milliseconds on UTC time.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UTCTimestamp

public UTCTimestamp()
Constructor via current UTC date.


UTCTimestamp

public UTCTimestamp(UTCTimestamp aTimestamp)
Constructor via given UTC timestamp (copy constructor).

Parameters:
aTimestamp -

UTCTimestamp

public UTCTimestamp(UTCTimestamp aDate,
                    UTCTimestamp aTime)
Constructor via given UTC date and time (combine constructor).

Parameters:
aDate - UTC date
aTime - UTC time

UTCTimestamp

public UTCTimestamp(String aTime)
Constructor via given date time string of UTC time.

Parameters:
aTime - date in format "yyyyMMdd-HH:mm:ss"

UTCTimestamp

public UTCTimestamp(Date aID)
Constructor via given date object.

Parameters:
aID - the Date in Local TimeZone
Method Detail

toString

public String toString()
Converts timestamp to string with UTC time.

Overrides:
toString in class Object
Returns:
"yyyyMMdd-HH:mm:ss" string.

toStringMs

public String toStringMs()
Temporary: Converts timestamp to string with milliseconds on UTC time.

Returns:
"yyyyMMdd-HH:mm:ss.SSS" string.

toDate

public Date toDate()
Converts timestamp to date object.

Returns:
Date object.

getTime

public long getTime()
Obtains the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this object.

Returns:
the number of milliseconds since January 1, 1970, 00:00:00 GMT.

addDuration

public UTCTimestamp addDuration(long aMsec)
Rolls up or down the timestamp value.

Parameters:
aMsec - time offset in millisecond to roll.
Returns:
this UTCTimestamp object rolled up or down

equals

public boolean equals(Object aObj)
Indicates whether some other object is "equal to" this one.

Overrides:
equals in class Object
Parameters:
aObj - Object
Returns:
true if this object is the same as the obj argument; false otherwise.

compareTo

public int compareTo(Object aObj)
Compares this object with the specified object for order.

Specified by:
compareTo in interface Comparable
Parameters:
aObj - Object
Returns:
true if this object is the same as the obj argument; false otherwise.

setDate

public void setDate(Date aTime)
Updates timestamp

Parameters:
aTime - new timestampt or null to setup current time

toString

public String toString(int aTimeZone)
Deprecated. use java.text.SimpleDateFormat approach

Converts timestamp to string with given timezone.

The java.text.SimpleDateFormat aproach:

   String tz = "GMT";
   if (aTimeZone > 0) {
       tz += "+";
   }
   tz += "" + aTimeZone + ":00";
   java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(""yyyyMMdd-HH:mm:ss"");
   sdf.setTimeZone(java.util.TimeZone.getTimeZone(tz));
   return sdf.format(toDate());
   

Parameters:
aTimeZone - time offset in hours
Returns:
"yyyyMMdd-HH:mm:ss" string.

toDateRef

public Date toDateRef()
Deprecated. There is no anymore such thing as internal Data object inside.

Originally: Obtains the reference to internal object state.

Now is same as toDate()

Returns:
new Date object instance.

toDate

public Date toDate(int aTimeZone)
Deprecated. Date object has no dependency on TimeZone.

Originally: Converts timestamp to date object with given TimeZone.

Now is same as toDate()

Parameters:
aTimeZone - time offset in hours
Returns:
new instance of Date object.

getLocalTimeZone

public static int getLocalTimeZone()
Deprecated. use java.util.Calendar aproach.

Obtains local timezone.

The java.util.Calendar aproach:

   java.util.Calendar cal = java.util.Calendar.getInstance();
   return (cal.get(java.util.Calendar.DST_OFFSET) +
      cal.get(java.util.Calendar.ZONE_OFFSET))
      /(60 * 60 * 1000);
   

Returns:
time offset in hours.

getLocalDate

public Date getLocalDate()
Deprecated. Date object has no dependency on TimeZone.

Originally: Obtains Date in Local Timezone.

Now is same as toDate()

Returns:
new instance of Date object.

setLocalDate

public void setLocalDate(Date aLocalTime)
Deprecated. Date object has no dependency on TimeZone.

Originally: Update Timestamp by given timestamp in local time.

Now is same as setDate()



Copyright © 2012 FXCM, LLC. All Rights Reserved.