org.kuali.rice.kns.util
Class DateUtils

java.lang.Object
  extended by org.apache.commons.lang.time.DateUtils
      extended by org.kuali.rice.kns.util.DateUtils

public class DateUtils
extends org.apache.commons.lang.time.DateUtils

Utility methods for comparing dates


Field Summary
 
Fields inherited from class org.apache.commons.lang.time.DateUtils
MILLIS_IN_DAY, MILLIS_IN_HOUR, MILLIS_IN_MINUTE, MILLIS_IN_SECOND, MILLIS_PER_DAY, MILLIS_PER_HOUR, MILLIS_PER_MINUTE, MILLIS_PER_SECOND, RANGE_MONTH_MONDAY, RANGE_MONTH_SUNDAY, RANGE_WEEK_CENTER, RANGE_WEEK_MONDAY, RANGE_WEEK_RELATIVE, RANGE_WEEK_SUNDAY, SEMI_MONTH, UTC_TIME_ZONE
 
Constructor Summary
DateUtils()
           
 
Method Summary
static java.sql.Date clearTimeFields(java.sql.Date date)
          Convert the given java.sql.date into a java.sql.date of which all the time fields are set to 0.
static java.util.Date clearTimeFields(java.util.Date date)
          Convert the given java.util.date into a java.util.date of which all the time fields are set to 0.
static java.sql.Date convertToSqlDate(java.util.Date date)
          Converts the given java.util.Date into an equivalent java.sql.Date
static double getDifferenceInDays(java.sql.Timestamp startDateTime, java.sql.Timestamp endDateTime)
           
static double getDifferenceInHours(java.sql.Timestamp startDateTime, java.sql.Timestamp endDateTime)
           
static boolean isSameDay(java.util.Calendar cal1, java.util.Calendar cal2)
          Adds null-safety to commons.DateUtils isSameDay method.
static boolean isSameDay(java.util.Date date1, java.util.Date date2)
          Adds null-safety to commons.DateUtils isSameDay method.
static java.sql.Date newDate(java.lang.Integer year, java.lang.Integer month, java.lang.Integer day)
          This method is a utility method to create a new java.sql.Date in one line.
static java.sql.Date newDate(java.lang.Integer year, java.lang.Integer month, java.lang.Integer day, java.lang.Integer hour, java.lang.Integer minute, java.lang.Integer second)
          This method is a utility method to create a new java.sql.Date in one line.
 
Methods inherited from class org.apache.commons.lang.time.DateUtils
add, addDays, addHours, addMilliseconds, addMinutes, addMonths, addSeconds, addWeeks, addYears, isSameInstant, isSameInstant, isSameLocalTime, iterator, iterator, iterator, parseDate, round, round, round, truncate, truncate, truncate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateUtils

public DateUtils()
Method Detail

isSameDay

public static boolean isSameDay(java.util.Date date1,
                                java.util.Date date2)
Adds null-safety to commons.DateUtils isSameDay method.

Returns:
true if both dates are null or represent the same day

isSameDay

public static boolean isSameDay(java.util.Calendar cal1,
                                java.util.Calendar cal2)
Adds null-safety to commons.DateUtils isSameDay method.

Returns:
true if both calendars are null or represent the same day

convertToSqlDate

public static java.sql.Date convertToSqlDate(java.util.Date date)
Converts the given java.util.Date into an equivalent java.sql.Date

Parameters:
date -
Returns:
java.sql.Date constructed from the given java.util.Date

clearTimeFields

public static java.sql.Date clearTimeFields(java.sql.Date date)
Convert the given java.sql.date into a java.sql.date of which all the time fields are set to 0.

Parameters:
date -
Returns:

clearTimeFields

public static java.util.Date clearTimeFields(java.util.Date date)
Convert the given java.util.date into a java.util.date of which all the time fields are set to 0.

Parameters:
date -
Returns:

getDifferenceInDays

public static double getDifferenceInDays(java.sql.Timestamp startDateTime,
                                         java.sql.Timestamp endDateTime)
Parameters:
startDateTime -
endDateTime -
Returns:
the difference in days between the second timestamp and first

getDifferenceInHours

public static double getDifferenceInHours(java.sql.Timestamp startDateTime,
                                          java.sql.Timestamp endDateTime)
Parameters:
startDateTime -
endDateTime -
Returns:
the difference in hours between the second timestamp and first

newDate

public static java.sql.Date newDate(java.lang.Integer year,
                                    java.lang.Integer month,
                                    java.lang.Integer day)
This method is a utility method to create a new java.sql.Date in one line.

Parameters:
year -
month -
day -
Returns:
a populated java.sql.Date with the year, month, and day specified, and no values for hour, minute, second, millisecond

newDate

public static java.sql.Date newDate(java.lang.Integer year,
                                    java.lang.Integer month,
                                    java.lang.Integer day,
                                    java.lang.Integer hour,
                                    java.lang.Integer minute,
                                    java.lang.Integer second)
This method is a utility method to create a new java.sql.Date in one line.

Parameters:
year -
month -
day -
hour -
minute -
second -
Returns:
a populated java.sql.Date with the year, month, hour, minute, and second populated, with no value for millisecond.


Copyright © 2004-2011 The Kuali Foundation. All Rights Reserved.