Project Wonder 5.0

er.extensions.foundation
Class ERXTimestampUtilities

java.lang.Object
  extended by er.extensions.foundation.ERXTimestampUtilities

public class ERXTimestampUtilities
extends java.lang.Object

Collection of NSTimestamp utilities.


Constructor Summary
ERXTimestampUtilities()
           
 
Method Summary
static com.webobjects.foundation.NSTimestamp dateByAddingTime(com.webobjects.foundation.NSTimestamp ts, com.webobjects.foundation.NSTimestamp t1)
          Deprecated. use timestampByAddingTime instead
static com.webobjects.foundation.NSTimestamp distantFuture()
          Deprecated. use NSTimestamp.DistantFuture instead
static com.webobjects.foundation.NSTimestamp distantPast()
          Deprecated. use NSTimestamp.DistantPast instead
static com.webobjects.foundation.NSTimestamp epoch()
          Utility method used to retrun the epoch, Jan 1st, 1970
static boolean isEarlierThan(com.webobjects.foundation.NSTimestamp ts1, com.webobjects.foundation.NSTimestamp ts2)
          Deprecated. use java.sql.Timestamp.before instead.
static boolean isLaterThan(com.webobjects.foundation.NSTimestamp ts1, com.webobjects.foundation.NSTimestamp ts2)
          Deprecated. use java.sql.Timestamp.after instead.
static java.lang.String simpleDateFormatForNSTimestampFormat(java.lang.String timestampFormatterPattern)
          Returns the SimpleDateFormat pattern given an NSTimestampFormatter pattern.
static com.webobjects.foundation.NSTimestamp timestampByAddingTime(com.webobjects.foundation.NSTimestamp ts, com.webobjects.foundation.NSTimestamp t1)
          Adds the time (hours, minutes and seconds) from the second timestamp to the first timestamp.
static com.webobjects.foundation.NSTimestamp timestampForString(java.lang.String defaultValue)
          Calculates a timestamp given a string.
static com.webobjects.foundation.NSTimestamp today()
          Timestamp representing today (12:00 AM).
static com.webobjects.foundation.NSTimestamp tomorrow()
          Timestamp representing tomorrow (12:00 AM).
static com.webobjects.foundation.NSTimestamp unixDate(java.lang.Number helpedNSNumber)
          Converts an offset from the epoch into a timestamp.
static java.lang.Integer unixTimestamp(com.webobjects.foundation.NSTimestamp ts)
          Converts a timestamp into the equivalent unix offset from the epoch.
static com.webobjects.foundation.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 com.webobjects.foundation.NSTimestamp timestampForString(java.lang.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 com.webobjects.foundation.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 com.webobjects.foundation.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 com.webobjects.foundation.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 com.webobjects.foundation.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 com.webobjects.foundation.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 com.webobjects.foundation.NSTimestamp dateByAddingTime(com.webobjects.foundation.NSTimestamp ts,
                                                                     com.webobjects.foundation.NSTimestamp t1)
Deprecated. use timestampByAddingTime instead


timestampByAddingTime

public static com.webobjects.foundation.NSTimestamp timestampByAddingTime(com.webobjects.foundation.NSTimestamp ts,
                                                                          com.webobjects.foundation.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(com.webobjects.foundation.NSTimestamp ts1,
                                    com.webobjects.foundation.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(com.webobjects.foundation.NSTimestamp ts1,
                                  com.webobjects.foundation.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 com.webobjects.foundation.NSTimestamp epoch()
Utility method used to retrun the epoch, Jan 1st, 1970

Returns:
the epoch as an NSTimestamp

unixDate

public static com.webobjects.foundation.NSTimestamp unixDate(java.lang.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 java.lang.Integer unixTimestamp(com.webobjects.foundation.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.

simpleDateFormatForNSTimestampFormat

public static java.lang.String simpleDateFormatForNSTimestampFormat(java.lang.String timestampFormatterPattern)
Returns the SimpleDateFormat pattern given an NSTimestampFormatter pattern. Note that these are not 100% compatible -- SimpleDateFormat properly implements DST and TimeZones whereas NSTimestampFormatter is ... kind of whacked, so you may notice your dates are off by a DST amount.

Parameters:
timestampFormatterPattern - the NSTimestampFormatter pattern
Returns:
a SimpleDateFormat pattern

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.