Project Wonder 2.0

er.extensions
Class ERXTimestampUtilities

java.lang.Object
  extended byer.extensions.ERXTimestampUtilities

public class ERXTimestampUtilities
extends Object

Collection of NSTimestamp utilities.


Constructor Summary
ERXTimestampUtilities()
           
 
Method Summary
static NSTimestamp dateByAddingTime(NSTimestamp ts, NSTimestamp t1)
          Deprecated. use timestampByAddingTime instead
static NSTimestamp distantFuture()
          Deprecated. use NSTimestamp.DistantFuture instead
static NSTimestamp distantPast()
          Deprecated. use NSTimestamp.DistantPast instead
static NSTimestamp epoch()
          Utility method used to retrun the epoch, Jan 1st, 1970
static boolean isEarlierThan(NSTimestamp ts1, NSTimestamp ts2)
          Deprecated. use java.sql.Timestamp.before instead.
static boolean isLaterThan(NSTimestamp ts1, NSTimestamp ts2)
          Deprecated. use java.sql.Timestamp.after instead.
static NSTimestamp timestampByAddingTime(NSTimestamp ts, NSTimestamp t1)
          Adds the time (hours, minutes and seconds) from the second timestamp to the first timestamp.
static NSTimestamp timestampForString(String defaultValue)
          Calculates a timestamp given a string.
static NSTimestamp today()
          Timestamp representing today (12:00 AM).
static NSTimestamp tomorrow()
          Timestamp representing tomorrow (12:00 AM).
static NSTimestamp unixDate(Number helpedNSNumber)
          Converts an offset from the epoch into a timestamp.
static Integer unixTimestamp(NSTimestamp ts)
          Converts a timestamp into the equivalent unix offset from the epoch.
static NSTimestamp yesterday()
          Timestamp representing yesterday (12:00 AM).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ERXTimestampUtilities

public ERXTimestampUtilities()
Method Detail

timestampForString

public static NSTimestamp timestampForString(String defaultValue)
Calculates a timestamp given a string. Currently supports the strings: now, today, yesterday, tomorrow, distantPast and distantFuture.

Parameters:
defaultValue - string given above
Returns:
timestamp equivalent to the string

today

public static NSTimestamp today()
Timestamp representing today (12:00 AM). Implementation wise this method subtracts the current hours, minutes and seconds from the current time.

Returns:
timestamp for today.

tomorrow

public static NSTimestamp tomorrow()
Timestamp representing tomorrow (12:00 AM). Implementation wise this method subtracts the current hours, minutes and seconds from the current time and then adds one day.

Returns:
timestamp for tomorrow.

yesterday

public static NSTimestamp yesterday()
Timestamp representing yesterday (12:00 AM). Implementation wise this method subtracts the current hours, minutes and seconds from the current time and then subtracts one day.

Returns:
timestamp for yesterday.

distantPast

public static NSTimestamp distantPast()
Deprecated. use NSTimestamp.DistantPast instead

Cover method for returning DistantPast off of NSTimestamp.

Returns:
a date in the distant past

distantFuture

public static NSTimestamp distantFuture()
Deprecated. use NSTimestamp.DistantFuture instead

Cover method for returning DistantFuture off of NSTimestamp.

Returns:
a date in the distant future

dateByAddingTime

public static NSTimestamp dateByAddingTime(NSTimestamp ts,
                                           NSTimestamp t1)
Deprecated. use timestampByAddingTime instead


timestampByAddingTime

public static NSTimestamp timestampByAddingTime(NSTimestamp ts,
                                                NSTimestamp t1)
Adds the time (hours, minutes and seconds) from the second timestamp to the first timestamp.

Parameters:
ts - timestamp to have the time added too.
t1 - timestamp to add the time from
Returns:
the first timestamp with the time of the second added to it.

isEarlierThan

public static boolean isEarlierThan(NSTimestamp ts1,
                                    NSTimestamp ts2)
Deprecated. use java.sql.Timestamp.before instead.

Compares two timestamps.

Parameters:
ts1 - first timestamp
ts2 - second timestamp
Returns:
true if the the second timestamp is earlier than the first timestamp.

isLaterThan

public static boolean isLaterThan(NSTimestamp ts1,
                                  NSTimestamp ts2)
Deprecated. use java.sql.Timestamp.after instead.

Compares two timestamps.

Parameters:
ts1 - first timestamp
ts2 - second timestamp
Returns:
true if the the second timestamp is later than the first timestamp.

epoch

public static NSTimestamp epoch()
Utility method used to retrun the epoch, Jan 1st, 1970

Returns:
the epoch as an NSTimestamp

unixDate

public static NSTimestamp unixDate(Number helpedNSNumber)
Converts an offset from the epoch into a timestamp.

Parameters:
helpedNSNumber - number offset from the epoch
Returns:
timestamp representation of the offset from the epoch.

unixTimestamp

public static Integer unixTimestamp(NSTimestamp ts)
Converts a timestamp into the equivalent unix offset from the epoch.

Parameters:
ts - timestamp to be converted
Returns:
timestamp represented as an integer offset from the epoch.

Last updated: Do, Dez 9, 2004 • 12:46 PM CET

Copyright © 2002 – 2004 Project Wonder.