com.mancrd.ahah.commons.utils
Class DateUtils

java.lang.Object
  extended by com.mancrd.ahah.commons.utils.DateUtils

public final class DateUtils
extends Object

Author:
timmolter

Method Summary
static Date addDays(Date date, int days)
          Add days to a date.
static Date addHours(Date date, int hours)
          Add hours to a date.
static Date addMinutes(Date date, int minutes)
          Add minutes to a date.
static Date addMonths(Date date, int months)
          Add months to a date.
static Date addSeconds(Date date, int seconds)
          Add seconds to a date.
static Date addYears(Date date, int years)
          Add years to a date.
static Date createTruncatedDate()
          Creates a current Date without timestamp
static Date getDateFromString(String dateString, String formatString)
          Given a Date String and a format String, returns a Date Object
static String getDateSQLString(Date date)
           
static String getDateTimeSQLString(Date date)
           
static long getDifferenceInDays(Date from, Date to)
           
static Date getLastDayOfMonth(Date date)
           
static Date getLastDayOfPreviousMonth(Date date)
           
static Date getNextBusinessDay(Date date)
           
static int getTimezoneDifference(String timezone1, String timezone2)
           
static boolean isFirstDayOfMonth(Date date)
          Check if given date is the first of the month
static boolean isNear(Date date1, Date date2, int days)
          Checks if the first date is near to the second date within the number of days specified
static boolean isSameDate(Date date1, Date date2)
          Check if two Date objects are the same date
static boolean isSameDateTime(Date date1, Date date2)
           
static boolean isToday(Date date)
          Check if the given date is today
static Date removeTimestamp(Date date)
          Removes the timestamp portion of a date
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDateFromString

public static Date getDateFromString(String dateString,
                                     String formatString)
                              throws ParseException
Given a Date String and a format String, returns a Date Object

Parameters:
dateString -
formatString -
Returns:
Throws:
ParseException

addYears

public static Date addYears(Date date,
                            int years)
Add years to a date. Use - sign to subtract years

Parameters:
date -
years -
Returns:

addMonths

public static Date addMonths(Date date,
                             int months)
Add months to a date. Use - sign to subtract months

Parameters:
date -
months -
Returns:

addDays

public static Date addDays(Date date,
                           int days)
Add days to a date. Use - sign to subtract days

Parameters:
date -
days -
Returns:

addHours

public static Date addHours(Date date,
                            int hours)
Add hours to a date. Use - sign to subtract hours

Parameters:
date -
hours -
Returns:

addMinutes

public static Date addMinutes(Date date,
                              int minutes)
Add minutes to a date. Use - sign to subtract minutes

Parameters:
date -
minutes -
Returns:

addSeconds

public static Date addSeconds(Date date,
                              int seconds)
Add seconds to a date. Use - sign to subtract seconds

Parameters:
date -
seconds -
Returns:

isNear

public static boolean isNear(Date date1,
                             Date date2,
                             int days)
Checks if the first date is near to the second date within the number of days specified

Parameters:
date1 -
date2 -
days -
Returns:

removeTimestamp

public static Date removeTimestamp(Date date)
Removes the timestamp portion of a date

Parameters:
date -
Returns:

getDateSQLString

public static String getDateSQLString(Date date)

getDateTimeSQLString

public static String getDateTimeSQLString(Date date)

isToday

public static boolean isToday(Date date)
Check if the given date is today

Parameters:
date -
Returns:

isSameDate

public static boolean isSameDate(Date date1,
                                 Date date2)
Check if two Date objects are the same date

Parameters:
date1 -
date2 -
Returns:

isFirstDayOfMonth

public static boolean isFirstDayOfMonth(Date date)
Check if given date is the first of the month

Parameters:
date -
Returns:

getLastDayOfPreviousMonth

public static Date getLastDayOfPreviousMonth(Date date)

getLastDayOfMonth

public static Date getLastDayOfMonth(Date date)

createTruncatedDate

public static Date createTruncatedDate()
Creates a current Date without timestamp

Returns:

getDifferenceInDays

public static long getDifferenceInDays(Date from,
                                       Date to)

getNextBusinessDay

public static Date getNextBusinessDay(Date date)

isSameDateTime

public static boolean isSameDateTime(Date date1,
                                     Date date2)

getTimezoneDifference

public static int getTimezoneDifference(String timezone1,
                                        String timezone2)


Copyright © 2013–2014 M. Alexander Nugent Consulting, Research and Devlopment. All rights reserved.