be.ac.ua.broker.utils
Class DateUtility

java.lang.Object
  extended by be.ac.ua.broker.utils.DateUtility

public class DateUtility
extends java.lang.Object

This class contains some date utilities needed in the application.

Author:
Vermeersch Kurt

Nested Class Summary
static class DateUtility.WeekDateFormat
          This class represents a DateFormatter that returns the week number of the date to format.
 
Field Summary
static long HOURINMILLISECONDS
          Representation of an hour in milliseconds
 
Constructor Summary
DateUtility()
           
 
Method Summary
static java.lang.String dateToString(java.util.Date date)
          Transform a date object to the string representation.
static java.util.Date earliestDateOfTheWeek(java.util.Date dateObj)
          Return the earliest date that lies in the same week as the given date
static java.lang.String getDayofTheDate(java.util.Date d)
          Getter for the day of the given date
static double getDoubleNumberOfHoursBetween(java.util.Date startDate, java.util.Date endDate)
          Getter for the double representation of the number of hours between a given start and end date
static int getNumberOfHoursBetween(java.util.Date startDate, java.util.Date endDate)
          Getter for the number of hours between a given start and end date
static int getNumberOfMinutesBetween(java.util.Date startDate, java.util.Date endDate)
          Getter for the number of minutes between a given start and end date
static int getWeekOfTheYear(java.util.Date date)
          Getter for the week number in the year in which the given date has place
static java.util.Date toDate(java.lang.String date)
          Convert the given string representation of a date to the actual date object using the date formatter
static java.lang.String toTime(java.util.Date date)
          Convert the given date to a string that represents the time of the date
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HOURINMILLISECONDS

public static long HOURINMILLISECONDS
Representation of an hour in milliseconds

Constructor Detail

DateUtility

public DateUtility()
Method Detail

getWeekOfTheYear

public static int getWeekOfTheYear(java.util.Date date)
Getter for the week number in the year in which the given date has place

Parameters:
date - the date to return the week number for
Returns:
the number of the week in the corresponding year

getDayofTheDate

public static java.lang.String getDayofTheDate(java.util.Date d)
Getter for the day of the given date

Parameters:
d - the date to return the day of
Returns:
the day of the given date

toDate

public static java.util.Date toDate(java.lang.String date)
Convert the given string representation of a date to the actual date object using the date formatter

Parameters:
date - the string representation of the date
Returns:
the actual date object for the given string representation of the date

toTime

public static java.lang.String toTime(java.util.Date date)
Convert the given date to a string that represents the time of the date

Parameters:
date - the date to return the string representation of the time for
Returns:
the string representation of the time of the given date

earliestDateOfTheWeek

public static java.util.Date earliestDateOfTheWeek(java.util.Date dateObj)
Return the earliest date that lies in the same week as the given date

Parameters:
dateObj - the date for which we have to determine the earliest date that lies in the same week as this date
Returns:
the earliest date that lies in the same week as the week that the given date lies in

getNumberOfHoursBetween

public static int getNumberOfHoursBetween(java.util.Date startDate,
                                          java.util.Date endDate)
Getter for the number of hours between a given start and end date

Parameters:
startDate - the lower boundary of the time interval
endDate - the upper boundary of the time interval
Returns:
the number of hours between startDate and endDates

getDoubleNumberOfHoursBetween

public static double getDoubleNumberOfHoursBetween(java.util.Date startDate,
                                                   java.util.Date endDate)
Getter for the double representation of the number of hours between a given start and end date

Parameters:
startDate - the lower boundary of the time interval
endDate - the upper boundary of the time interval
Returns:
the double representation of the number of hours between startDate and endDates

getNumberOfMinutesBetween

public static int getNumberOfMinutesBetween(java.util.Date startDate,
                                            java.util.Date endDate)
Getter for the number of minutes between a given start and end date

Parameters:
startDate - the lower boundary of the time interval
endDate - the upper boundary of the time interval
Returns:
the number of minutes between startDate and endDates

dateToString

public static java.lang.String dateToString(java.util.Date date)
Transform a date object to the string representation.

Parameters:
date - the date to transform
Returns:
the formatted string representation of the given date