org.apache.empire.commons
Class DateUtils

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

public class DateUtils
extends Object

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


Method Summary
static Date addDate(Date date, int years, int months, int days)
          Calculates a date relative to the supplied date.
static String formatDate(Date d, Locale locale)
           
static String formatDayOfWeek(Date d, Locale locale, boolean longFormat)
           
static String formatMonth(Date d, Locale locale, boolean longFormat)
           
static String formatMonth(int month, Locale locale, boolean longFormat)
           
static String formatTime(Date d, Locale locale, boolean withSeconds)
           
static String formatYear(Date d, Locale locale)
           
static Date getDate(int year, int month, int day)
           
static Date getDateNow()
          Returns the current date without time
static Date getDateOnly(Date date)
           
static Date getTimeNow()
          Returns the current date and time
static int getWeekOfYear(Date d, Locale locale)
           
static Date parseDate(String sDate, Locale locale)
           
static Date setDate(Date date, int year, int month, int day)
           
static Date setTime(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

getDateNow

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

Returns:
the date

getTimeNow

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

Returns:
the date

addDate

public static Date addDate(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 Date setDate(Date date,
                           int year,
                           int month,
                           int day)

getDate

public static Date getDate(int year,
                           int month,
                           int day)

setTime

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

getDateOnly

public static Date getDateOnly(Date date)

parseDate

public static Date parseDate(String sDate,
                             Locale locale)

formatDate

public static String formatDate(Date d,
                                Locale locale)

formatTime

public static String formatTime(Date d,
                                Locale locale,
                                boolean withSeconds)

formatDayOfWeek

public static String formatDayOfWeek(Date d,
                                     Locale locale,
                                     boolean longFormat)

formatMonth

public static String formatMonth(Date d,
                                 Locale locale,
                                 boolean longFormat)

getWeekOfYear

public static int getWeekOfYear(Date d,
                                Locale locale)

formatMonth

public static String formatMonth(int month,
                                 Locale locale,
                                 boolean longFormat)

formatYear

public static String formatYear(Date d,
                                Locale locale)


Copyright © 2008–2014 Apache Software Foundation. All rights reserved.