Holger's
Java API

com.antelmann.calendar
Class CalendarUtils

java.lang.Object
  extended by com.antelmann.calendar.CalendarUtils

public final class CalendarUtils
extends Object

methods that require a calendar for calculation are synchronized, so they do not perform simultaneously

Author:
Holger Antelmann

Field Summary
static SimpleDateFormat ietfDateFormat
          the IETF date format is used in HTTP headers for displaying the date.
 
Method Summary
static int age(Date birthday)
           
static Comparator<Date> createBirthdayComparator()
          returns a newly created comparator that will compare the dates by ignoring the year
static Date dayBegin(Date d)
          returns a date that is set to the begin of the given day (daytime 12:00 a.m.)
static int dayOfWeek(Date date)
           
static Date monthBegin(Date d)
           
static Date nextDay(Date d)
          returns a date that is exactly a day later
static Date nextMonth(Date d)
          returns a date that is exactly a month later
static Date nextWeek(Date d)
          returns a date that is exactly a week later
static Date nextYear(Date d)
          returns a date that is exactly a year later
static int offset(Date date)
          returns the offset that must be adjusted due to timezone specific daylight saving times
static boolean sameDay(Date d1, Date d2)
          returns true only if the two dates are within the same day
static void setCalendar(Calendar calendar)
          by default, the standard GregorianCalendar is used
static int timeInDay(Date date)
          returns milliseconds from the beginning of the day
static Date weekBegin(Date d)
           
static Date yearBegin(Date d)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ietfDateFormat

public static final SimpleDateFormat ietfDateFormat
the IETF date format is used in HTTP headers for displaying the date. Since Java deprecated java.util.Date.parse(String), this offers an easy way to make the IETF date format work in any non-deprecated API.

Method Detail

setCalendar

public static void setCalendar(Calendar calendar)
by default, the standard GregorianCalendar is used


dayOfWeek

public static int dayOfWeek(Date date)
See Also:
Calendar.DAY_OF_WEEK

timeInDay

public static int timeInDay(Date date)
returns milliseconds from the beginning of the day


offset

public static int offset(Date date)
returns the offset that must be adjusted due to timezone specific daylight saving times


sameDay

public static boolean sameDay(Date d1,
                              Date d2)
returns true only if the two dates are within the same day


dayBegin

public static Date dayBegin(Date d)
returns a date that is set to the begin of the given day (daytime 12:00 a.m.)


weekBegin

public static Date weekBegin(Date d)

monthBegin

public static Date monthBegin(Date d)

yearBegin

public static Date yearBegin(Date d)

nextDay

public static Date nextDay(Date d)
returns a date that is exactly a day later


nextWeek

public static Date nextWeek(Date d)
returns a date that is exactly a week later


nextMonth

public static Date nextMonth(Date d)
returns a date that is exactly a month later


nextYear

public static Date nextYear(Date d)
returns a date that is exactly a year later


age

public static int age(Date birthday)

createBirthdayComparator

public static Comparator<Date> createBirthdayComparator()
returns a newly created comparator that will compare the dates by ignoring the year



(c) 2001-2006 Holger Antelmann - all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads