edu.rice.rubis.beans
Class TimeManagement

java.lang.Object
  |
  +--java.util.Calendar
        |
        +--java.util.GregorianCalendar
              |
              +--edu.rice.rubis.beans.TimeManagement
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class TimeManagement
extends java.util.GregorianCalendar

This class provides additionnal functions that the GregorianCalendar class does not provide. It is mainly to compute time differences and display the date in a database understandable format.

Version:
1.0
Author:
Emmanuel Cecchet and Julie Marguerite
See Also:
Serialized Form

Fields inherited from class java.util.GregorianCalendar
AD, BC
 
Fields inherited from class java.util.Calendar
AM, AM_PM, APRIL, areFieldsSet, AUGUST, DATE, DAY_OF_MONTH, DAY_OF_WEEK, DAY_OF_WEEK_IN_MONTH, DAY_OF_YEAR, DECEMBER, DST_OFFSET, ERA, FEBRUARY, FIELD_COUNT, fields, FRIDAY, HOUR, HOUR_OF_DAY, isSet, isTimeSet, JANUARY, JULY, JUNE, MARCH, MAY, MILLISECOND, MINUTE, MONDAY, MONTH, NOVEMBER, OCTOBER, PM, SATURDAY, SECOND, SEPTEMBER, SUNDAY, THURSDAY, time, TUESDAY, UNDECIMBER, WEDNESDAY, WEEK_OF_MONTH, WEEK_OF_YEAR, YEAR, ZONE_OFFSET
 
Constructor Summary
TimeManagement()
          Creates a new TimeManagement instance.
 
Method Summary
static java.util.GregorianCalendar addDays(java.util.GregorianCalendar startDate, int durationInDays)
          Compute a new GregorianCalendar from a beginning date and a duration in days.
static java.lang.String currentDateToString()
          Returns a string representation of the current date (when the method is called) conforming to the following database format : 'YYYY-MM-DD hh:mm:ss'
static java.lang.String dateToString(java.util.GregorianCalendar d)
          Returns a string representation of a date conforming to the following database format : 'YYYY-MM-DD hh:mm:ss'
static java.lang.String diffTime(java.util.GregorianCalendar startDate, java.util.GregorianCalendar endDate)
          Returns a string representation of the time elapsed between startDate and endDate.
static long diffTimeInMs(java.util.GregorianCalendar startDate, java.util.GregorianCalendar endDate)
          Returns the time elapsed between startDate and endDate in milliseconds
 
Methods inherited from class java.util.GregorianCalendar
add, computeFields, computeTime, equals, getActualMaximum, getActualMinimum, getGreatestMinimum, getGregorianChange, getLeastMaximum, getMaximum, getMinimum, hashCode, isLeapYear, roll, roll, setGregorianChange
 
Methods inherited from class java.util.Calendar
after, before, clear, clear, clone, complete, get, getAvailableLocales, getFirstDayOfWeek, getInstance, getInstance, getInstance, getInstance, getMinimalDaysInFirstWeek, getTime, getTimeInMillis, getTimeZone, internalGet, isLenient, isSet, set, set, set, set, setFirstDayOfWeek, setLenient, setMinimalDaysInFirstWeek, setTime, setTimeInMillis, setTimeZone, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TimeManagement

public TimeManagement()
Creates a new TimeManagement instance.
Method Detail

currentDateToString

public static java.lang.String currentDateToString()
Returns a string representation of the current date (when the method is called) conforming to the following database format : 'YYYY-MM-DD hh:mm:ss'
Returns:
current date in database format

dateToString

public static java.lang.String dateToString(java.util.GregorianCalendar d)
Returns a string representation of a date conforming to the following database format : 'YYYY-MM-DD hh:mm:ss'
Parameters:
d - a GregorianCalendar value
Returns:
current date in database format

diffTimeInMs

public static long diffTimeInMs(java.util.GregorianCalendar startDate,
                                java.util.GregorianCalendar endDate)
Returns the time elapsed between startDate and endDate in milliseconds
Parameters:
startDate - beginning date
endDate - ending date
Returns:
elapsed time in milliseconds

diffTime

public static java.lang.String diffTime(java.util.GregorianCalendar startDate,
                                        java.util.GregorianCalendar endDate)
Returns a string representation of the time elapsed between startDate and endDate. Example of a returned string : "1 month 3 days 6 hours 33 minutes 4 seconds 234 milliseconds"
Parameters:
startDate - beginning date
endDate - ending date
Returns:
string containing the time difference up to the millisecond

addDays

public static java.util.GregorianCalendar addDays(java.util.GregorianCalendar startDate,
                                                  int durationInDays)
Compute a new GregorianCalendar from a beginning date and a duration in days.
Parameters:
startDate - beginning date
durationInDays - number of days to add to startDate.
Returns:
date corresponding to startDate+durationInDays


Copyright © 2003 - ObjectWeb Consortium - All Rights Reserved.