net.wotonomy.foundation
Class NSDate

java.lang.Object
  extended by java.util.Date
      extended by net.wotonomy.foundation.NSDate
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<java.util.Date>

public class NSDate
extends java.util.Date

A pure java implementation of NSDate that extends java.util.Date for greater java compatibility.

Version:
$Revision: 892 $
Author:
michael@mpowers.net, $Author: cgruber $
See Also:
Serialized Form

Field Summary
static int NSOrderedAscending
           
static int NSOrderedDescending
           
static int NSOrderedSame
           
 
Constructor Summary
NSDate()
          Default constructor represents the current date.
NSDate(double seconds)
          Represents the specified number of seconds from the current date.
NSDate(double seconds, java.util.Date sinceDate)
          Represents the specified number of seconds from the specified date.
 
Method Summary
 int compare(java.util.Date aDate)
          Returns a negative value if the specified date is later than this date, a positive value if the specified date is earlier than this date, or zero if the dates are equal.
static double currentTimeIntervalSinceReferenceDate()
          Returns the number of seconds between now and the reference date.
 NSDate dateByAddingTimeInterval(double seconds)
          Returns a date that differs from this date by the specified number of seconds.
static NSDate distantFuture()
          Returns a date that is greater than all representable dates.
static NSDate distantPast()
          Returns a date that is less than all representable dates.
 NSDate earlierDate(NSDate aDate)
          Compares this date to the specified date and returns the earlier date.
 boolean isEqualToDate(java.util.Date aDate)
          Returns whether the this date is equal to the specified date, per the result of equals().
 NSDate laterDate(NSDate aDate)
          Compares this date to the specified date and returns the later date.
static double millisecondsToTimeInterval(long millis)
          Converts milliseconds to seconds.
 double timeIntervalSinceDate(java.util.Date aDate)
          Returns the interval between this date and the specified date in seconds.
 double timeIntervalSinceNow()
          Returns the interval between this date and the current date in seconds.
 double timeIntervalSinceReferenceDate()
          Returns the interval between this date and 1 January 2001 GMT.
static long timeIntervalToMilliseconds(double seconds)
          Converts seconds to milliseconds.
 
Methods inherited from class java.util.Date
after, before, clone, compareTo, equals, getDate, getDay, getHours, getMinutes, getMonth, getSeconds, getTime, getTimezoneOffset, getYear, hashCode, parse, setDate, setHours, setMinutes, setMonth, setSeconds, setTime, setYear, toGMTString, toLocaleString, toString, UTC
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NSOrderedAscending

public static final int NSOrderedAscending
See Also:
Constant Field Values

NSOrderedSame

public static final int NSOrderedSame
See Also:
Constant Field Values

NSOrderedDescending

public static final int NSOrderedDescending
See Also:
Constant Field Values
Constructor Detail

NSDate

public NSDate()
Default constructor represents the current date.


NSDate

public NSDate(double seconds)
Represents the specified number of seconds from the current date.


NSDate

public NSDate(double seconds,
              java.util.Date sinceDate)
Represents the specified number of seconds from the specified date.

Method Detail

timeIntervalSinceReferenceDate

public double timeIntervalSinceReferenceDate()
Returns the interval between this date and 1 January 2001 GMT.


timeIntervalSinceDate

public double timeIntervalSinceDate(java.util.Date aDate)
Returns the interval between this date and the specified date in seconds.


timeIntervalSinceNow

public double timeIntervalSinceNow()
Returns the interval between this date and the current date in seconds.


earlierDate

public NSDate earlierDate(NSDate aDate)
Compares this date to the specified date and returns the earlier date. Unspecified which is returned if both are equal.


laterDate

public NSDate laterDate(NSDate aDate)
Compares this date to the specified date and returns the later date. Unspecified which is returned if both are equal.


compare

public int compare(java.util.Date aDate)
Returns a negative value if the specified date is later than this date, a positive value if the specified date is earlier than this date, or zero if the dates are equal. The return values are compatible with type NSComparisonResult.


isEqualToDate

public boolean isEqualToDate(java.util.Date aDate)
Returns whether the this date is equal to the specified date, per the result of equals().


dateByAddingTimeInterval

public NSDate dateByAddingTimeInterval(double seconds)
Returns a date that differs from this date by the specified number of seconds.


currentTimeIntervalSinceReferenceDate

public static double currentTimeIntervalSinceReferenceDate()
Returns the number of seconds between now and the reference date.


timeIntervalToMilliseconds

public static long timeIntervalToMilliseconds(double seconds)
Converts seconds to milliseconds. Included for compatibility.


millisecondsToTimeInterval

public static double millisecondsToTimeInterval(long millis)
Converts milliseconds to seconds. Included for compatibility.


distantFuture

public static NSDate distantFuture()
Returns a date that is greater than all representable dates.


distantPast

public static NSDate distantPast()
Returns a date that is less than all representable dates.



Copyright © 2006 null. All Rights Reserved.