FileDocCategorySizeDatePackage
Timestamp.javaAPI DocExample2436Thu Oct 13 14:57:32 BST 2005com.samscdrental.model.adt

Timestamp

public class Timestamp extends Object implements Serializable

Title: Sams CD Rental Store

Description:

Copyright: Copyright (c) 2004

Company:

author
Ken Pugh
version
1.0

Fields Summary
private static final long
serialVersionUID
private Date
theDate
private static final long
NUMBER_MILLISECONDS_IN_DAY
Constructors Summary
public Timestamp()

 

	 
	
		// Will be initialized to the current time
		theDate = new Date();
	
Methods Summary
public com.samscdrental.model.adt.TimestampaddDays(int days)
add

param
days int
return
Timestamp

		long thisMilliseconds = this.theDate.getTime();
		long thatMilliseconds = thisMilliseconds +
			days * NUMBER_MILLISECONDS_IN_DAY;

		Timestamp aTimestamp = new Timestamp();
		aTimestamp.theDate = new Date( thatMilliseconds );
		return aTimestamp;
	
public intdifferenceInDays(com.samscdrental.model.adt.Timestamp aTimestamp)
subtract

param
aTimestamp Timestamp
return
int - Number of Days

		long thisMilliseconds = this.theDate.getTime();
		long thatMilliseconds = aTimestamp.theDate.getTime();
		long millisecondsDifference = thisMilliseconds - thatMilliseconds;
		int days = ( int ) ( millisecondsDifference /
							 NUMBER_MILLISECONDS_IN_DAY );

		return days;

	
public booleanequals(com.samscdrental.model.adt.Timestamp aTimestamp)
Indicates whether some other object is "equal to" this one.

param
obj the reference object with which to compare.
return
true if this object is the same as the obj argument; false otherwise.
todo
Implement this java.lang.Object method

		return theDate.equals( aTimestamp.theDate );
	
public booleanequals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one.

param
obj the reference object with which to compare.
return
true if this object is the same as the obj argument; false otherwise.
todo
Implement this java.lang.Object method

		return equals( ( Timestamp ) obj );
	
public java.lang.StringtoString()
Returns a string representation of the object.

return
a string representation of the object.
todo
Implement this java.lang.Object method

		return theDate.toString();