net.sf.oness.common.model.temporal
Class Date

java.lang.Object
  extended bynet.sf.oness.common.all.BaseObject
      extended bynet.sf.oness.common.model.temporal.Date
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable, java.io.Serializable

public class Date
extends net.sf.oness.common.all.BaseObject
implements java.lang.Comparable

Wrapper around a Calendar object truncated to the field specified (by default SECOND) using DateUtils.truncate(Calendar, int).

The MIN_VALUE and MAX_VALUE fields represent negative and positive infinity respectively, the implementation doesn't use Calendar.getMinimum or Calendar.getMaximum because the underlying database may not accept the range of values available in Calendar

Version:
$Revision: 1.6 $
Author:
Carlos Sanchez
See Also:
Calendar, DateUtils.truncate(Calendar,int), Serialized Form

Field Summary
protected  java.util.Calendar calendar
          Wrapped calendar
static Date MAX_VALUE
          The max value (actually 9999-DEC-31 23:59:59)
static Date MIN_VALUE
          The min value (actually 1000-JAN-01 00:00:00)
 
Fields inherited from class net.sf.oness.common.all.BaseObject
log
 
Constructor Summary
Date()
          Create Date not initialized.
Date(java.util.Calendar calendar)
          Create a date from a Calendar truncated to the default field DEFAULT_TRUNCATE_TO_FIELDleaving it as the most significant.
Date(java.util.Calendar calendar, int truncateToField)
          Create a date from a Calendar truncated to the field specified leaving it as the most significant.
Date(int year, int month, int day)
          Create a Date from year, month, day
Date(int year, int month, int day, int hour, int minute, int second)
          Create a Date from year, month, day, hour, minute, second
 
Method Summary
 void addDays(int arg)
           
 void addYears(int arg)
           
 boolean after(Date when)
           
 boolean before(Date when)
           
 java.lang.Object clone()
           
 int compareTo(java.lang.Object arg)
           
 boolean equals(java.lang.Object o)
           
 java.util.Calendar getCalendar()
          Get the Calendar wrapped by this object.
 int getDayOfMonth()
           
 int getMonth()
           
 java.util.Date getTime()
          Get this Time as a java.util.Date object.
 int getYear()
           
 int hashCode()
           
static Date now()
          Create a Date for the current time and truncated to the default field DEFAULT_TRUNCATE_TO_FIELDleaving it as the most significant.
 void setCalendar(java.util.Calendar calendar)
          Set the Calendar wrapped by this object.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MIN_VALUE

public static final Date MIN_VALUE
The min value (actually 1000-JAN-01 00:00:00)


MAX_VALUE

public static final Date MAX_VALUE
The max value (actually 9999-DEC-31 23:59:59)


calendar

protected java.util.Calendar calendar
Wrapped calendar

Constructor Detail

Date

public Date()
Create Date not initialized.


Date

public Date(int year,
            int month,
            int day,
            int hour,
            int minute,
            int second)
Create a Date from year, month, day, hour, minute, second

Parameters:
year -
month -
day -
hour -
minute -
second -

Date

public Date(int year,
            int month,
            int day)
Create a Date from year, month, day

Parameters:
year -
month -
day -

Date

public Date(java.util.Calendar calendar,
            int truncateToField)
Create a date from a Calendar truncated to the field specified leaving it as the most significant.
Future changes to the calendar will not affect the newly created object

Parameters:
calendar -
truncateToField -

Date

public Date(java.util.Calendar calendar)
Create a date from a Calendar truncated to the default field DEFAULT_TRUNCATE_TO_FIELDleaving it as the most significant.
Future changes to the calendar will not affect the newly created object

Parameters:
calendar -
Method Detail

now

public static Date now()
Create a Date for the current time and truncated to the default field DEFAULT_TRUNCATE_TO_FIELDleaving it as the most significant.


getCalendar

public java.util.Calendar getCalendar()
Get the Calendar wrapped by this object. Changes to the Calendar will affect this date.

Returns:
the calendar

setCalendar

public void setCalendar(java.util.Calendar calendar)
Set the Calendar wrapped by this object. Changes to the Calendar will affect this date.

Parameters:
calendar -

after

public boolean after(Date when)
Parameters:
when -
Returns:
See Also:
Calendar.after(java.lang.Object)

before

public boolean before(Date when)
Parameters:
when -
Returns:
See Also:
Calendar.before(java.lang.Object)

compareTo

public int compareTo(java.lang.Object arg)
Specified by:
compareTo in interface java.lang.Comparable
Parameters:
arg -
Returns:
See Also:
Date.compareTo(java.lang.Object)

getTime

public java.util.Date getTime()
Get this Time as a java.util.Date object.

Returns:
See Also:
Calendar.getTime()

addDays

public void addDays(int arg)

addYears

public void addYears(int arg)

getYear

public int getYear()

getMonth

public int getMonth()

getDayOfMonth

public int getDayOfMonth()

toString

public java.lang.String toString()

equals

public boolean equals(java.lang.Object o)
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
See Also:
Object.hashCode()

clone

public java.lang.Object clone()
See Also:
Object.clone()


Copyright © 2003-2005 ONess Project. All Rights Reserved.