com.funambol.util
Class DateUtil

java.lang.Object
  extended by com.funambol.util.DateUtil

public class DateUtil
extends java.lang.Object

Utility class for date manipulation. This class gives a simple interface for common Date, Calendar and Timezone operations. It is possible to apply subsequent transformations to an initial date, and retrieve the changed Date object at any point.


Constructor Summary
DateUtil()
          Inizialize a new instance with the current date
DateUtil(java.util.Date d)
          Inizialize a new instance with the given date
 
Method Summary
 DateUtil addMinutes(int minutes)
          Make the date go forward of the specified amount of minutes The internal date is changed after this call.
 int getDaysSince(java.util.Date date)
          Get the days passed from the specified date up to the date provided in the constructor
 java.util.Date getTime()
          Get the current time
 java.lang.String getTZ()
          Get the current TimeZone
 boolean isAfter(java.util.Date date)
          Utility method wrapping Calendar.after method Compares the date field parameter with the date provided with the constructor answering the question: date from constructor is after the given param date ?
 DateUtil removeDays(int days)
          Make the date go back of the specified amount of days The internal date is changed after this call.
 void setTime(java.util.Date d)
          Set a new time
 DateUtil toGMT()
          Convert the date to GMT.
 DateUtil toMidnight()
          Convert the time to the midnight of the currently set date.
 DateUtil toTZ(java.lang.String tz)
          Convert the date to the given timezone.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateUtil

public DateUtil()
Inizialize a new instance with the current date


DateUtil

public DateUtil(java.util.Date d)
Inizialize a new instance with the given date

Method Detail

setTime

public void setTime(java.util.Date d)
Set a new time


getTime

public java.util.Date getTime()
Get the current time


getTZ

public java.lang.String getTZ()
Get the current TimeZone


toMidnight

public DateUtil toMidnight()
Convert the time to the midnight of the currently set date. The internal date is changed after this call.

Returns:
a reference to this DateUtil, for concatenation.

removeDays

public DateUtil removeDays(int days)
Make the date go back of the specified amount of days The internal date is changed after this call.

Returns:
a reference to this DateUtil, for concatenation.

addMinutes

public DateUtil addMinutes(int minutes)
Make the date go forward of the specified amount of minutes The internal date is changed after this call.

Returns:
a reference to this DateUtil, for concatenation.

toGMT

public DateUtil toGMT()
Convert the date to GMT. The internal date is changed

Returns:
a reference to this DateUtil, for concatenation.

toTZ

public DateUtil toTZ(java.lang.String tz)
Convert the date to the given timezone. The internal date is changed.

Parameters:
tz - The name of the timezone to set
Returns:
a reference to this DateUtil, for concatenation.

getDaysSince

public int getDaysSince(java.util.Date date)
Get the days passed from the specified date up to the date provided in the constructor

Parameters:
date - The starting date
Returns:
number of days within date used in constructor and the provided date

isAfter

public boolean isAfter(java.util.Date date)
Utility method wrapping Calendar.after method Compares the date field parameter with the date provided with the constructor answering the question: date from constructor is after the given param date ?

Parameters:
date - The date to be used for comparison
Returns:
true if date from constructor is after given param date


Copyright © 2006 Funambol.