com.calitha.util
Class DateUtil

java.lang.Object
  extended by com.calitha.util.DateUtil

public final class DateUtil
extends Object

The DateUtil class contains a collection of convenience methods for using dates and calendars.

Author:
Robert van Loenhout

Method Summary
static String formatCalendar(Calendar calendar, String pattern)
          Formats a calendar.
static String formatCalendar(Calendar calendar, String pattern, TimeZone timezone)
          Formats a calendar.
static String formatCurrentDate(String pattern)
          Formats the current date.
static String formatDate(Date date, String pattern)
          Formats a date.
static String formatDate(Date date, String pattern, TimeZone timezone)
          Formats a date.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

formatDate

public static String formatDate(Date date,
                                String pattern,
                                TimeZone timezone)
Formats a date.

The date is formatted by applying the pattern. The timezone determines the offset compared to GMT.

Parameters:
date - date to be formatted
pattern - pattern that determines the format of the date
timezone - timezone
Returns:
date as a string
Throws:
IllegalArgumentException - if an argument is null

formatDate

public static String formatDate(Date date,
                                String pattern)
Formats a date.

The date is formatted by applying the pattern. The default system timezone is used.

Parameters:
date - date to be formatted
pattern - pattern that determines the format of the date
Returns:
date as a string
Throws:
IllegalArgumentException - if an argument is null

formatCurrentDate

public static String formatCurrentDate(String pattern)
Formats the current date.

The date is formatted by applying the pattern. The default systen timezone is used.

Parameters:
pattern - pattern that determines the format of the date
Returns:
date as a string
Throws:
IllegalArgumentException - if an argument is null

formatCalendar

public static String formatCalendar(Calendar calendar,
                                    String pattern)
Formats a calendar.

The calendar is formatted by applying the pattern. The default system timezone is used.

Parameters:
calendar - calender to be formatted
pattern - pattern that determines the format of the date
Returns:
calendar as a string
Throws:
IllegalArgumentException - if an argument is null

formatCalendar

public static String formatCalendar(Calendar calendar,
                                    String pattern,
                                    TimeZone timezone)
Formats a calendar.

The calendar is formatted by applying the pattern. The timezone determines the offset compared to GMT.

Parameters:
calendar - calender to be formatted
pattern - pattern that determines the format of the date
timezone - timezone used to format the date
Returns:
calendar as a string
Throws:
IllegalArgumentException - if an argument is null