org.apache.empire.commons
Class DateUtils

java.lang.Object
  extended by org.apache.empire.commons.DateUtils

public class DateUtils
extends java.lang.Object

This class contains common functions for comparing and converting values of type Date.


Method Summary
static java.util.Date addDate(java.util.Date date, int years, int months, int days)
          Calculates a date relative to the supplied date.
static java.lang.String formatDate(java.util.Date d, java.util.Locale locale)
           
static java.lang.String formatDayOfWeek(java.util.Date d, java.util.Locale locale, boolean longFormat)
           
static java.lang.String formatMonth(java.util.Date d, java.util.Locale locale, boolean longFormat)
           
static java.lang.String formatMonth(int month, java.util.Locale locale, boolean longFormat)
           
static java.lang.String formatTime(java.util.Date d, java.util.Locale locale, boolean withSeconds)
           
static java.lang.String formatYear(java.util.Date d, java.util.Locale locale)
           
static java.util.Date getDate(int year, int month, int day)
           
static java.util.Date getDateNow()
          Returns the current date without time
static java.util.Date getDateOnly(java.util.Date date)
           
static java.util.Date getDateTimeFromNow(boolean withTime, int years, int months, int days)
          returns a date relative from the current date.
static java.util.Date getTimeNow()
          Returns the current date and time
static int getWeekOfYear(java.util.Date d, java.util.Locale locale)
           
static java.util.Date parseDate(java.lang.String sDate, java.util.Locale locale)
           
static java.util.Date setDate(java.util.Date date, int year, int month, int day)
           
static java.util.Date setTime(java.util.Date date, int hours, int minutes, int seconds, int millis)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDateTimeFromNow

public static java.util.Date getDateTimeFromNow(boolean withTime,
                                                int years,
                                                int months,
                                                int days)
returns a date relative from the current date.

Parameters:
withTime - true if the current time should be added or false if only the date is desired.
years - number of years to add or subtract from the current date
months - number of months to add or subtract from the current date
days - number of days to add or subtract from the current date
Returns:
the target date

getDateNow

public static java.util.Date getDateNow()
Returns the current date without time

Returns:
the date

getTimeNow

public static java.util.Date getTimeNow()
Returns the current date and time

Returns:
the date

addDate

public static java.util.Date addDate(java.util.Date date,
                                     int years,
                                     int months,
                                     int days)
Calculates a date relative to the supplied date.

Parameters:
date - date to calculate from
years - number of years to add or subtract from the supplied date
months - number of months to add or subtract from the supplied date
days - number of days to add or subtract from the supplied date
Returns:
the target date

setDate

public static java.util.Date setDate(java.util.Date date,
                                     int year,
                                     int month,
                                     int day)

getDate

public static java.util.Date getDate(int year,
                                     int month,
                                     int day)

setTime

public static java.util.Date setTime(java.util.Date date,
                                     int hours,
                                     int minutes,
                                     int seconds,
                                     int millis)

getDateOnly

public static java.util.Date getDateOnly(java.util.Date date)

parseDate

public static java.util.Date parseDate(java.lang.String sDate,
                                       java.util.Locale locale)

formatDate

public static java.lang.String formatDate(java.util.Date d,
                                          java.util.Locale locale)

formatTime

public static java.lang.String formatTime(java.util.Date d,
                                          java.util.Locale locale,
                                          boolean withSeconds)

formatDayOfWeek

public static java.lang.String formatDayOfWeek(java.util.Date d,
                                               java.util.Locale locale,
                                               boolean longFormat)

formatMonth

public static java.lang.String formatMonth(java.util.Date d,
                                           java.util.Locale locale,
                                           boolean longFormat)

getWeekOfYear

public static int getWeekOfYear(java.util.Date d,
                                java.util.Locale locale)

formatMonth

public static java.lang.String formatMonth(int month,
                                           java.util.Locale locale,
                                           boolean longFormat)

formatYear

public static java.lang.String formatYear(java.util.Date d,
                                          java.util.Locale locale)


Copyright © 2008-2011 Apache Software Foundation. All Rights Reserved.