Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.metacosm.framework.world
Class Date  view Date download Date.java

java.lang.Object
  extended byorg.metacosm.framework.world.Date
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable, java.io.Serializable

public class Date
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable, java.lang.Comparable

Date is a common representation for time in all the worlds.
This has nothing to do with seconds, minutes, hours, days, weeks, months, seasons, years, decades, centuries, millenaries, eras, eons, etc. These notions suppose a planet with one sun, a week of 7 days, etc. Each world should provide its own Date converter. Date contains a timestamp given by the game clock at its creation. BE CAREFUL: java.util.Date and org.metacosm.framework.world.Date should not be mixed up.


Field Summary
private  long timestamp
           
 
Constructor Summary
Date()
          Allocates a Date object and initializes it so that it represents the time (given by the game clock) at which it was allocated.
Date(long timestamp)
          Allocates a Date object and initializes it so that it represents the time after timestamp ticks.
 
Method Summary
 boolean after(Date when)
          Tests if this date is after the specified date.
 boolean before(Date when)
          Tests if this date is before the specified date.
 int compareTo(Date date)
          Compares two Dates for ordering.
 int compareTo(java.lang.Object o)
          Compares this Date to another Object.
If the Object is a Date, this function behaves like compareTo(Date).
 boolean equals(java.lang.Object obj)
          Compares two dates for equality.
 long getTicks()
           
 void setTicks(long ticks)
          Sets this Date object to represent a point in time that is ticks ticks after game clock started
 java.lang.String toString()
          Convert this Object to a human-readable String.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

timestamp

private long timestamp
Constructor Detail

Date

public Date()
Allocates a Date object and initializes it so that it represents the time (given by the game clock) at which it was allocated.


Date

public Date(long timestamp)
Allocates a Date object and initializes it so that it represents the time after timestamp ticks.

Method Detail

after

public final boolean after(Date when)
Tests if this date is after the specified date.


before

public final boolean before(Date when)
Tests if this date is before the specified date.


compareTo

public final int compareTo(java.lang.Object o)
Compares this Date to another Object.
If the Object is a Date, this function behaves like compareTo(Date). Otherwise, it throws a ClassCastException (as Dates are comparable only to other Dates).

Specified by:
compareTo in interface java.lang.Comparable

compareTo

public final int compareTo(Date date)
Compares two Dates for ordering.


equals

public final boolean equals(java.lang.Object obj)
Compares two dates for equality.


getTicks

public final long getTicks()

setTicks

public void setTicks(long ticks)
Sets this Date object to represent a point in time that is ticks ticks after game clock started


toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).