WebObjects 5.4.2

com.webobjects.foundation
Class NSTimestamp

java.lang.Object
  extended by java.util.Date
      extended by java.sql.Timestamp
          extended by com.webobjects.foundation.NSTimestamp
All Implemented Interfaces:
NSCoding, Serializable, Cloneable, Comparable

public class NSTimestamp
extends Timestamp
implements NSCoding

NSTimestamp objects represent a particular instant in time. Unlike the NSGregorianDate class in previous versions of the Foundation framework, NSTimestamp does not support calendar functions. Refer to the table below to determine which classes to use to perform date operations in WebObjects.

Class Description
NSTimestamp represents an instant in time
java.util.GregorianCalendar represents a calendar date
NSTimeZone represents a time zone
NSTimestampFormatter converts NSTimestamps to strings and vice versa

This class's absolute reference date is the first instant of 1 January 1970, 00:00:00, GMT.

NSTimestamp

Common Date Operations

For the following code segments, you need to import java.util.* to access Java's date API.

To break up a NSTimestamp into its component year, month, day, hour, etc., you can convert it into a java.util.GregorianCalendar and invoke its get method on the individual fields:

 <blockquote>
  NSTimestamp myNSTimestamp = new NSTimestamp();
  GregorianCalendar myCalendar = new GregorianCalendar();
  myCalendar.setTime(myNSTimestamp);
  int year = myCalendar.get(GregorianCalendar.YEAR);
  int dayOfMonth = myCalendar.get(GregorianCalendar.DAY_OF_MONTH);
  </blockquote>
 

To create an NSTimestamp based on its components, use the following code:

 <blockquote>
  NSTimeZone tz = NSTimeZone.timeZoneWithName("America/Los_Angeles", true);
  NSTimestamp myNSTimestamp = new NSTimestamp(year, month, day, hour, minute, seconds, tz);
  </blockquote>
 

To add an offset in Gregorian units to an NSTimestamp, use the following code:

 <blockquote>
  NSTimestamp myNSTimestamp = (new NSTimestamp()).timestampByAddingGregorianUnits(year, month, day, hour, minute, seconds);
  </blockquote>
 

To create an NSTimestamp representing the current time, use the no-argument constructor:

 <blockquote>
  NSTimestamp currentTime = new NSTimestamp();
  </blockquote>
 

The Enterprise Objects Framework expects dates to be represented as NSTimestamp objects. To convert a java.util.Date to an NSTimestamp use:

 <blockquote>
  NSTimestamp myNSTimestamp = new NSTimestamp(myJavaUtilDate);
  </blockquote>
 

Since NSTimestamp is a subclass of java.util.Date, you don't need to convert an NSTimestamp into a java.util.Date.

NSTimestamp does not maintain time zone information. All NSTimestamps are 64 bit millisecond offsets since the reference date in the reference time zone. This is January 1, 1970, 00:00:00 GMT.

NSTimestamp.getTime()'s behavior matches that of java.util.Date, NOT java.sql.Timestamp. java.sql.Timestamp.getTime() returns a value with a precision of 1 second. Both NSTimestamp and java.util.Date return a value with a precision of 1 millisecond. java.sql.Timestamps have all fractional seconds in their nanosecond field, while NSTimestamps only place fractions of milliseconds in their nanosecond field.

See Also:
NSTimestamp.getTime(), NSTimestampFormatter, NSTimeZone, Date, GregorianCalendar, Timestamp, Serialized Form

Nested Class Summary
static class NSTimestamp.IntRef
          Deprecated. in the Java Foundation framework. NSTimestamp.IntRef objects act as a containers to hold the values returned by NSTimestamp's gregorianUnitsSinceTimestamp method and consist solely of an instance variable, value.
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSCoding
NSCoding.Support
 
Field Summary
static NSTimestamp DistantFuture
          An NSTimestamp that represents a date in the distant future (in terms of centuries).
static NSTimestamp DistantPast
          An NSTimestamp that represents a date in the distant past (in terms of centuries).
 
Constructor Summary
NSTimestamp()
          Creates an NSTimestamp representing the current time, accurate to the millisecond.
NSTimestamp(Date date)
          Creates an NSTimestamp from a Date.
NSTimestamp(int year, int month, int date, int hour, int minute, int second, TimeZone tz)
          Creates an NSTimestamp representing the specified year, month,day, hours, minutes, and seconds in the specified time zone.
NSTimestamp(long time)
          Creates an NSTimestamp representing the specified number of milliseconds since the reference date, January 1, 1970, 00:00:00 GMT.
NSTimestamp(long milliseconds, int nanoseconds)
          Creates an NSTimestamp representing the specified number of milliseconds and nanoseconds since the reference date, January 1, 1970, 00:00:00 GMT.
NSTimestamp(long time, int nanos, TimeZone tz)
          Creates an NSTimestamp object representing the specified number of milliseconds and nanoseconds since the reference date in the specified time zone.
NSTimestamp(long time, NSTimestamp date)
          Creates an NSTimestamp object representing the specified number of milliseconds after the time specified by date.
NSTimestamp(long time, TimeZone tz)
          Creates an NSTimestamp representing the specified number of milliseconds since the reference date in the specified time zone.
NSTimestamp(Timestamp sqlTimestamp)
          Creates an NSTimestamp from a java.sql.Timestamp.
 
Method Summary
 Class classForCoder()
          Conformance to the NSCoding interface
 int compare(NSTimestamp ts)
          Determines whether this NSTimestamp is before, after, or the same as another NSTimestamp.
static long currentTimeIntervalSinceReferenceDate()
          Deprecated. Use (System.currentTimeMillis() / 1000) instead
 long dayOfCommonEra()
          Deprecated. Use GregorianCalendar instead.
 int dayOfMonth()
          Deprecated. Use GregorianCalendar instead.
 int dayOfWeek()
          Deprecated. Use GregorianCalendar instead.
 int dayOfYear()
          Deprecated. Use GregorianCalendar instead.
static Object decodeObject(NSCoder coder)
          Provides an NSTimestamp from data in coder.
static NSTimestamp distantFuture()
          Deprecated. Use NSTimestamp.DistantFuture instead
static NSTimestamp distantPast()
          Deprecated. Use NSTimestamp.DistantPast
 NSTimestamp earlierTimestamp(NSTimestamp ts)
          Deprecated. Use before instead
 void encodeWithCoder(NSCoder coder)
          Encodes the receiver using coder.
 int getNanos()
           
 long getTime()
          NSTimestamp.getTime()'s behavior matches that of java.util.Date, NOT java.sql.Timestamp.
 void gregorianUnitsSinceTimestamp(NSTimestamp.IntRef years, NSTimestamp.IntRef months, NSTimestamp.IntRef days, NSTimestamp.IntRef hours, NSTimestamp.IntRef minutes, NSTimestamp.IntRef seconds, NSTimestamp time)
          Deprecated.  
 int hourOfDay()
          Deprecated. Use GregorianCalendar instead.
 NSTimestamp laterTimestamp(NSTimestamp ts)
          Deprecated. Use after instead
 int microsecondOfSecond()
          Deprecated. Do not use this method. Java typically uses milliseconds, not microseconds.
static long millisecondsToTimeInterval(long milliseconds)
          Deprecated. Use (milliseconds / 1000) instead
 int minuteOfHour()
          Deprecated. Use GregorianCalendar instead.
 int monthOfYear()
          Deprecated. Use GregorianCalendar instead.
 int secondOfMinute()
          Deprecated. Use GregorianCalendar instead.
 void setDate(int date)
          Deprecated. NSTimestamp objects are immutable.
 void setHours(int hours)
          Deprecated. NSTimestamp objects are immutable.
 void setMinutes(int minutes)
          Deprecated. NSTimestamp objects are immutable.
 void setMonth(int month)
          Deprecated. NSTimestamp objects are immutable.
 void setNanos(int nanoseconds)
          Deprecated. NSTimestamp objects are immutable.
 void setSeconds(int seconds)
          Deprecated. NSTimestamp objects are immutable.
 void setTime(long time)
          Deprecated. NSTimestamp objects are immutable.
 void setYear(int year)
          Deprecated. NSTimestamp objects are immutable.
 long timeIntervalSinceNow()
          Deprecated. Use getTime and calculate the delta from System.currentTimeMillis instead
 long timeIntervalSinceReferenceDate()
          Deprecated. Use (getTime() / 1000) instead.
 long timeIntervalSinceTimestamp(NSTimestamp ts)
          Deprecated. Use getTime and calculate the delta instead
static long timeIntervalToMilliseconds(long timeInterval)
          Deprecated. Use (timeInterval * 1000) instead
 NSTimestamp timestampByAddingGregorianUnits(int years, int months, int days, int hours, int minutes, int seconds)
          Returns an NSTimestamp that is updated with the years, months, days, hours, minutes, and seconds offsets specified as arguments.
 NSTimestamp timestampByAddingTimeInterval(long interval)
          Deprecated. Use (new NSTimestamp((interval * 1000) + oldTs.getTime(), oldTs.getNanos())) instead.
 NSTimeZone timeZone()
          Deprecated. Deprecated in the Java Foundation framework. Do not use this method. All NSTimestamps are in UTC.
 String toString()
           
 int yearOfCommonEra()
          Deprecated. Use GregorianCalendar instead.
 
Methods inherited from class java.sql.Timestamp
after, before, compareTo, compareTo, equals, equals, valueOf
 
Methods inherited from class java.util.Date
after, before, clone, getDate, getDay, getHours, getMinutes, getMonth, getSeconds, getTimezoneOffset, getYear, hashCode, parse, toGMTString, toLocaleString, UTC
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DistantPast

public static final NSTimestamp DistantPast
An NSTimestamp that represents a date in the distant past (in terms of centuries).


DistantFuture

public static final NSTimestamp DistantFuture
An NSTimestamp that represents a date in the distant future (in terms of centuries).

Constructor Detail

NSTimestamp

public NSTimestamp()
Creates an NSTimestamp representing the current time, accurate to the millisecond.


NSTimestamp

public NSTimestamp(long time)
Creates an NSTimestamp representing the specified number of milliseconds since the reference date, January 1, 1970, 00:00:00 GMT.

Parameters:
time - milliseconds since the reference date

NSTimestamp

public NSTimestamp(long milliseconds,
                   int nanoseconds)
Creates an NSTimestamp representing the specified number of milliseconds and nanoseconds since the reference date, January 1, 1970, 00:00:00 GMT.

Parameters:
milliseconds - milliseconds since the reference date
nanoseconds - nanoseconds in addition to milliseconds

NSTimestamp

public NSTimestamp(long time,
                   NSTimestamp date)
Creates an NSTimestamp object representing the specified number of milliseconds after the time specified by date.

Parameters:
time - offset in milliseconds
date - input date after which the time is to be calculated

NSTimestamp

public NSTimestamp(long time,
                   TimeZone tz)
Creates an NSTimestamp representing the specified number of milliseconds since the reference date in the specified time zone.

NSTimestamp does not maintain time zone information. All NSTimestamps are millisecond offsets since the reference date in the reference time zone. This method assumes time is a time from the tz time zone, and converts time into a time appropriate for NSTimestamp to handle.

Parameters:
time - time in milliseconds
tz - new time zone

NSTimestamp

public NSTimestamp(long time,
                   int nanos,
                   TimeZone tz)
Creates an NSTimestamp object representing the specified number of milliseconds and nanoseconds since the reference date in the specified time zone.

NSTimestamp does not maintain time zone information. All NSTimestamps are millisecond offsets since the reference date in the reference time zone. This method assumes time is a time from the tz time zone, and converts time into a time appropriate for NSTimestamp to handle.

Parameters:
time - time in milliseconds
nanos - time in nanoseconds
tz - time zone

NSTimestamp

public NSTimestamp(int year,
                   int month,
                   int date,
                   int hour,
                   int minute,
                   int second,
                   TimeZone tz)
Creates an NSTimestamp representing the specified year, month,day, hours, minutes, and seconds in the specified time zone. Note especially that NSTimestamp denotes months as values from 1 to 12, so that 1 = January, 2 = February, etc. java.util date classes index months from zero ( 0 = January, 1 = February, etc.), so if you extract the month value from a java.util date object, you need to correct for this difference by adding one before passing the value to this constructor, and vice versa.

The arguments should specify dates which fall within the range of 1583 C.E. - 4000 C.E. Other dates may suffer from loss of precision, or only remain valid as long as they are not rendered human readable. Dates before DistantPast or after DistantFuture will result in an IllegalArgumentException.

Parameters:
year - year where DistantPast < year < DistantFuture
month - month where 1 <= month <= 12
date - date where 1 <= date <= 31
hour - hour where 0 <= hour <= 23
minute - minute where 0 <= minute <= 59
second - second where 0 <= second <= 59
tz - time zone
Throws:
IllegalArgumentException - (year <= DistantPast.yearOfCommonEra()) || (year >= DistantFuture.yearOfCommonEra())

NSTimestamp

public NSTimestamp(Date date)
Creates an NSTimestamp from a Date.

Parameters:
date - Date to use to initialize the new NSTimestamp
See Also:
Date

NSTimestamp

public NSTimestamp(Timestamp sqlTimestamp)
Creates an NSTimestamp from a java.sql.Timestamp.

Parameters:
sqlTimestamp - Timestamp to use to initialize the new NSTimestamp
See Also:
Timestamp
Method Detail

currentTimeIntervalSinceReferenceDate

@Deprecated
public static long currentTimeIntervalSinceReferenceDate()
Deprecated. Use (System.currentTimeMillis() / 1000) instead

Returns:
the number of seconds between the reference date and the current date and time.
See Also:
System.currentTimeMillis()

distantFuture

@Deprecated
public static NSTimestamp distantFuture()
Deprecated. Use NSTimestamp.DistantFuture instead

Provides an NSTimestamp that represents a date many centuries in the future. You can pass this value where an NSTimestamp is required to have the date argument essentially ignored. For example, the NSLock method tryLock(NSTimeStamp) returns false if the receiver fails to acquire the lock before the specified date. You can use the object returned by distantFuture as the date argument to wait indefinitely to acquire the lock.

Returns:
NSTimestamp that represents a date many centuries in the future
See Also:
NSTimestamp.DistantFuture

distantPast

@Deprecated
public static NSTimestamp distantPast()
Deprecated. Use NSTimestamp.DistantPast

Provides an NSTimestamp that represents a date many centuries in the past. You can use this object in your code as a control date, a guaranteed temporal boundary.

Returns:
NSTimestamp that represents a date many centuries in the past
See Also:
NSTimestamp.DistantPast

millisecondsToTimeInterval

@Deprecated
public static long millisecondsToTimeInterval(long milliseconds)
Deprecated. Use (milliseconds / 1000) instead

Indicates the time interval in seconds corresponding to the specified time represented in milliseconds. Any fractional part of a second is truncated.

Parameters:
milliseconds - time in milliseconds
Returns:
time interval in seconds corresponding to the specified time represented in seconds

timeIntervalToMilliseconds

@Deprecated
public static long timeIntervalToMilliseconds(long timeInterval)
Deprecated. Use (timeInterval * 1000) instead

Returns a time interval in milliseconds corresponding to the specified timeInterval represented in seconds.

Parameters:
timeInterval - time interval in seconds
Returns:
time interval in milliseconds corresponding to the specified time interval represented in seconds

classForCoder

public Class classForCoder()
Conformance to the NSCoding interface

Specified by:
classForCoder in interface NSCoding
Returns:
NSTimestamp.class
See Also:
NSCoding

decodeObject

public static Object decodeObject(NSCoder coder)
Provides an NSTimestamp from data in coder.

Parameters:
coder - NSCoder from which to obtain the timestamp
Returns:
new NSTimestamp
See Also:
NSCoding

encodeWithCoder

public void encodeWithCoder(NSCoder coder)
Description copied from interface: NSCoding
Encodes the receiver using coder. Object type information along with an object's data is stored.

Specified by:
encodeWithCoder in interface NSCoding
Parameters:
coder - an NSCoder object that will be used to encode object of classes that implement this interface
See Also:
NSCoder

timestampByAddingGregorianUnits

public NSTimestamp timestampByAddingGregorianUnits(int years,
                                                   int months,
                                                   int days,
                                                   int hours,
                                                   int minutes,
                                                   int seconds)
Returns an NSTimestamp that is updated with the years, months, days, hours, minutes, and seconds offsets specified as arguments. The offsets can be positive (future) or negative (past). This method preserves "clock time" across changes in Daylight Savings Time zones and leap years. For example, adding one month to an NSTimestamp with a time of 12 noon correctly maintains time at 12 noon.

The following code fragment shows an NSTimestamp created with a date a week later than an existing NSTimestamp.

 <blockquote>
  NSTimestamp now = new NSTimestamp();
  NSTimestamp nextWeek = now.timestampByAddingGregorianUnits(0, 0, 7, 0, 0, 0);
  </blockquote>
 

Parameters:
years - input value of year
months - input value of months
days - input value of days
hours - input value of hours
minutes - input value of minutes
seconds - input value of seconds
Returns:
NSTimestamp that is updated with the year, month, day,hour, minute, and second offsets specified as arguments.

timestampByAddingTimeInterval

@Deprecated
public NSTimestamp timestampByAddingTimeInterval(long interval)
Deprecated. Use (new NSTimestamp((interval * 1000) + oldTs.getTime(), oldTs.getNanos())) instead.

Returns an NSTimestamp with the specified time interval in seconds added to this NSTimestamp's time.

Parameters:
interval - input time interval in seconds
Returns:
Returns an NSTimestamp with the specified time interval in milliseconds added to this NSTimestamp's time.

dayOfCommonEra

@Deprecated
public long dayOfCommonEra()
Deprecated. Use GregorianCalendar instead.

Returns:
the number of days since the beginning of the Common Era. The base year of the Common Era is 1 C.E. (which is the same as 1 A.D.).
See Also:
GregorianCalendar

dayOfMonth

@Deprecated
public int dayOfMonth()
Deprecated. Use GregorianCalendar instead.

Indicates the day of the month for this NSTimestamp.

Returns:
1 through 31
See Also:
GregorianCalendar

dayOfWeek

@Deprecated
public int dayOfWeek()
Deprecated. Use GregorianCalendar instead.

Indicates the day of the week for this NSTimestamp. Returns a number that indicates the day of the week (0 through 6) of the receiver; 0 indicates Sunday.

Returns:
0 through 6; 0 = Sunday
See Also:
GregorianCalendar

dayOfYear

@Deprecated
public int dayOfYear()
Deprecated. Use GregorianCalendar instead.

Indicates the day of the year for this NSTimestamp.

Returns:
1 through 366
See Also:
GregorianCalendar

hourOfDay

@Deprecated
public int hourOfDay()
Deprecated. Use GregorianCalendar instead.

Returns the hour value (0 through 23) of this NSTimestamp. On Daylight Savings "fall back" days, a value of 1 is returned for two consecutive hours, but with a different time zone (the first in daylight savings time and the second in standard time).

Returns:
the hour value (0 through 23) of this NSTimestamp
See Also:
GregorianCalendar

microsecondOfSecond

@Deprecated
public int microsecondOfSecond()
Deprecated. Do not use this method. Java typically uses milliseconds, not microseconds.

Returns the microseconds value of this NSTimestamp.

Returns:
the microseconds value (0 through 999999) of the receiver
See Also:
NSTimestamp.getTime(), GregorianCalendar

minuteOfHour

@Deprecated
public int minuteOfHour()
Deprecated. Use GregorianCalendar instead.

Returns the minutes value of this NSTimestamp.

Returns:
the minutes value (0 through 59) of this NSTimestamp.
See Also:
GregorianCalendar

monthOfYear

@Deprecated
public int monthOfYear()
Deprecated. Use GregorianCalendar instead.

Returns a number that indicates the month of the year of this NSTimestamp. Note that java.util.Calendar represents months as integers from 0 to 11.

Returns:
the month of the year (1 through 12) of this NSTimestamp
See Also:
GregorianCalendar

secondOfMinute

@Deprecated
public int secondOfMinute()
Deprecated. Use GregorianCalendar instead.

Returns the seconds value of this NSTimestamp.

Returns:
the seconds value (0 through 59) of this NSTimestamp
See Also:
GregorianCalendar

yearOfCommonEra

@Deprecated
public int yearOfCommonEra()
Deprecated. Use GregorianCalendar instead.

Returns:
number that indicates the year, including the century, of this NSTimestamp (for example, 1995). The base year of the Common Era is 1 C.E. (which is the same as 1 A.D.).
See Also:
GregorianCalendar

gregorianUnitsSinceTimestamp

@Deprecated
public void gregorianUnitsSinceTimestamp(NSTimestamp.IntRef years,
                                                    NSTimestamp.IntRef months,
                                                    NSTimestamp.IntRef days,
                                                    NSTimestamp.IntRef hours,
                                                    NSTimestamp.IntRef minutes,
                                                    NSTimestamp.IntRef seconds,
                                                    NSTimestamp time)
Deprecated. 

Computes the time difference in calendar units between this NSTimestamp and timestamp and returns it in years, months, days, hours, minutes, and seconds. NSTimestamp.IntRef is a local class that contains a single element: the integer value.

You can choose any representation you wish for the time difference by passing null for the arguments you want to ignore. For example, the following code fragment computes the difference in months, days, and years between two dates:

 <blockquote>
  NSTimestamp momsBDay = new NSTimestamp(1936, 1, 8, 7, 30, 0, java.util.TimeZone.getTimeZone("EST"));
  NSTimestamp dateOfBirth = new NSTimestamp(1965, 12, 7, 17, 25, 0, new NSTimeZone("EST"));
  NSTimestamp.IntRef years = new NSTimestamp.IntRef();
  NSTimestamp.IntRef months = new NSTimestamp.IntRef();
  NSTimestamp.IntRef days = new NSTimestamp.IntRef();
  dateOfBirth.gregorianUnitsSinceTimestamp(momsBDay,
  years, months, days, null, null, null)</blockquote>
 

If you want to express the years in terms of months, you pass null for the years argument:

 <blockquote>
  dateOfBirth.gregorianUnitsSinceTimestamp(momsBDay, null, months, days, null, null, null);
  </blockquote>
 
This message returns 358 months and 29 days.

Parameters:
years - year
months - mongth
days - days
hours - hours
minutes - minutes
seconds - seconds
time - timestamp

timeIntervalSinceTimestamp

@Deprecated
public long timeIntervalSinceTimestamp(NSTimestamp ts)
Deprecated. Use getTime and calculate the delta instead

Returns the number of seconds between this NSTimestamp's time and ts. This value is negative if this NSTimestamp's time is earlier than time.

Parameters:
ts - timestamp
Returns:
number of seconds between this NSTimestamp's time and time.
See Also:
NSTimestamp.getTime()

timeIntervalSinceNow

@Deprecated
public long timeIntervalSinceNow()
Deprecated. Use getTime and calculate the delta from System.currentTimeMillis instead

Returns the number of seconds between this NSTimestamp's time and the current system time. This value is negative if this NSTimestamp's time is earlier than the current system time.

Returns:
Returns the number of seconds between the receiver's time and the current system time.
See Also:
NSTimestamp.getTime(), System.currentTimeMillis()

timeIntervalSinceReferenceDate

@Deprecated
public long timeIntervalSinceReferenceDate()
Deprecated. Use (getTime() / 1000) instead.

Returns the number of seconds between this NSTimestamp's time and the reference date. This value is negative if this NSTimestamp's time is earlier than the reference date.

Returns:
number of seconds between the receiver's time and the reference date
See Also:
NSTimestamp.getTime()

compare

public int compare(NSTimestamp ts)
Determines whether this NSTimestamp is before, after, or the same as another NSTimestamp. Returns an integer indicating whether the receiver is before, after, or the same as ts. If the receiver is before ts, this method returns NSComparator.OrderedAscending. If the receiver is after ts, this method returns NSComparator.OrderedDescending. If the dates match, this method returns NSComparator.OrderedSame.

Parameters:
ts - input timestamp
Returns:
NSComparator.OrderedAscending when ts is after this NSTimestamp, NSComparator.OrderedDescending when ts is before this NSTimestamp, NSComparator.OrderedSame when ts and this NSTimestamp are equal
See Also:
NSComparator

earlierTimestamp

@Deprecated
public NSTimestamp earlierTimestamp(NSTimestamp ts)
Deprecated. Use before instead

Determines the earliest of this NSTimestamp and another NSTimestamp.

Parameters:
ts - the other timestamp
Returns:
the earliest of this NSTimestamp and ts
See Also:
Timestamp.before(java.sql.Timestamp)

laterTimestamp

@Deprecated
public NSTimestamp laterTimestamp(NSTimestamp ts)
Deprecated. Use after instead

Determines the later of this NSTimestamp and another NSTimestamp.

Parameters:
ts - the other timestamp
Returns:
the later of this NSTimestamp and ts
See Also:
Timestamp.after(java.sql.Timestamp)

toString

public String toString()
Overrides:
toString in class Timestamp
Returns:
string representation of this NSTimestamp

timeZone

@Deprecated
public NSTimeZone timeZone()
Deprecated. Deprecated in the Java Foundation framework. Do not use this method. All NSTimestamps are in UTC.

Returns:
This always returns NSTimeZone for GMT
See Also:
NSTimeZone

setNanos

@Deprecated
public void setNanos(int nanoseconds)
Deprecated. NSTimestamp objects are immutable.

NSTimestamp objects are immutable.

Overrides:
setNanos in class Timestamp
Parameters:
nanoseconds - input nanoseconds value to be specified

setDate

@Deprecated
public void setDate(int date)
Deprecated. NSTimestamp objects are immutable.

Overrides:
setDate in class Date
Parameters:
date - date value to be specified

setHours

@Deprecated
public void setHours(int hours)
Deprecated. NSTimestamp objects are immutable.

Overrides:
setHours in class Date
Parameters:
hours - input hour value to be specified

setMinutes

@Deprecated
public void setMinutes(int minutes)
Deprecated. NSTimestamp objects are immutable.

Overrides:
setMinutes in class Date
Parameters:
minutes - input minutes value to be specified

setMonth

@Deprecated
public void setMonth(int month)
Deprecated. NSTimestamp objects are immutable.

Overrides:
setMonth in class Date
Parameters:
month - input month value to be specified

setSeconds

@Deprecated
public void setSeconds(int seconds)
Deprecated. NSTimestamp objects are immutable.

NSTimestamp objects are immutable.

Overrides:
setSeconds in class Date
Parameters:
seconds - input seconds value to be specified

setTime

@Deprecated
public void setTime(long time)
Deprecated. NSTimestamp objects are immutable.

Overrides:
setTime in class Timestamp
Parameters:
time - input time to be specified

getTime

public long getTime()
NSTimestamp.getTime()'s behavior matches that of java.util.Date, NOT java.sql.Timestamp. java.sql.Timestamp.getTime() returns a value with a precision of 1 second. Both NSTimestamp and java.util.Date return a value with a precision of 1 millisecond. java.sql.Timestamps have all fractional seconds in their nanosecond field, while NSTimestamps only place fractions of milliseconds in their nanosecond field. This means the nanosecond field of a java.sql.Timestamp and NSTimestamp which both represent the same offset from the reference date may be different values. The reference date is January 1, 1970, 00:00:00 GMT

Overrides:
getTime in class Timestamp
Returns:
The number of milliseconds since the reference date that this NSTimestamp represents.
See Also:
Date.getTime(), Timestamp.getTime()

getNanos

public int getNanos()
Overrides:
getNanos in class Timestamp

setYear

@Deprecated
public void setYear(int year)
Deprecated. NSTimestamp objects are immutable.

Overrides:
setYear in class Date
Parameters:
year - input year value to be specified

Last updated June 2008

Copyright © 2000-2008 Apple Inc.