|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.calendar.CalendarHelper
public final class CalendarHelper
methods that require a calendar for calculation are synchronized, so they do not perform simultaneously
| Field Summary | |
|---|---|
static SimpleDateFormat |
IETF_DATE_FORMAT
the IETF date format is used in HTTP headers for displaying the date. |
| Constructor Summary | |
|---|---|
CalendarHelper()
|
|
CalendarHelper(Calendar calendar)
|
|
| Method Summary | |
|---|---|
Date |
addDays(Date date,
int n)
|
int |
age(Date birthday)
|
static Comparator<Date> |
createBirthdayComparator()
returns a newly created comparator that will compare the dates by ignoring the year |
Date |
dayBegin(Date d)
returns a date that is set to the begin of the given day (daytime 12:00 a.m.) |
Date |
dayEnd(Date d)
|
int |
dayInMonth(Date d)
|
int |
dayOfWeek(Date date)
|
int |
daysBetween(Date a,
Date b)
based on 24h difference adjusted by daylight savings time |
int |
daysInMonth(Date d)
|
int |
differenceInDays(Date a,
Date b)
based on the date rather than the exact time in between |
int |
getBusinessYear(Date date,
int monthOfYearBegin)
|
int |
getBusinessYear(Date date,
Month monthOfYearBegin)
|
Calendar |
getCalendar()
returns the currently used Calendar instance |
Date |
getDateForYear(int year)
|
int |
getYear(Date date)
|
boolean |
isAnniversary(Date anniversary,
Date referenceDate)
|
boolean |
isLastDayInMonth(Date d)
|
boolean |
isWeekend(Date date)
|
int |
month(Date d)
|
Date |
monthBegin(Date d)
|
Date |
monthEnd(Date d)
|
Date |
nextDay(Date d)
returns a date that is exactly a day later |
Date |
nextMonth(Date d)
returns a date that is exactly a month later |
Date |
nextQuarter(Date d)
returns a date that is exactly 3 months later |
Date |
nextWeek(Date d)
returns a date that is exactly a week later |
Date |
nextYear(Date d)
returns a date that is exactly a year later |
int |
offset(Date date)
returns the offset that must be adjusted due to timezone specific daylight saving times |
Date |
previousDay(Date d)
|
Date |
previousMonth(Date d)
|
Date |
previousQuarter(Date d)
|
Date |
previousWeek(Date d)
|
Date |
previousYear(Date d)
|
Date |
quarterBegin(Date d)
|
boolean |
sameDay(Date d1,
Date d2)
returns true only if the two dates are within the same day given the default time zone |
boolean |
sameDayOfWeek(Date d1,
Date d2)
|
boolean |
sameMonth(Date d1,
Date d2)
|
boolean |
sameWeek(Date d1,
Date d2)
|
boolean |
sameYear(Date d1,
Date d2)
|
void |
setCalendar(Calendar calendar)
by default, the standard GregorianCalendar is used |
int |
timeInDay(Date date)
returns milliseconds from the beginning of the day |
Date |
weekBegin(Date d)
week begins Monday here |
int |
weekInMonth(Date d)
|
int |
weekInYear(Date d)
|
int |
y2k(int twoDigitYear)
returns an educated guess for the actual year that was meant |
Date |
yearBegin(Date d)
|
Date |
yearEnd(Date d)
|
Date |
yearToDate(int year)
|
long |
zoneDiff(TimeZone tz,
long timeInMillis)
returns the difference in times from the currently used calendar to the given zone at the specified point in time |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final SimpleDateFormat IETF_DATE_FORMAT
java.util.Date.parse(String),
this offers an easy way to make the IETF date format work in any
non-deprecated API.
| Constructor Detail |
|---|
public CalendarHelper()
public CalendarHelper(Calendar calendar)
| Method Detail |
|---|
public Calendar getCalendar()
public void setCalendar(Calendar calendar)
public int getYear(Date date)
public int getBusinessYear(Date date,
Month monthOfYearBegin)
public int getBusinessYear(Date date,
int monthOfYearBegin)
public boolean isWeekend(Date date)
public int dayOfWeek(Date date)
Calendar.DAY_OF_WEEKpublic int timeInDay(Date date)
TimeInDay
public long zoneDiff(TimeZone tz,
long timeInMillis)
public int offset(Date date)
public boolean isAnniversary(Date anniversary,
Date referenceDate)
public boolean sameDay(Date d1,
Date d2)
public boolean sameDayOfWeek(Date d1,
Date d2)
public boolean sameYear(Date d1,
Date d2)
public boolean sameWeek(Date d1,
Date d2)
public boolean sameMonth(Date d1,
Date d2)
public Date dayEnd(Date d)
public Date dayBegin(Date d)
public Date weekBegin(Date d)
public Date monthBegin(Date d)
public Date monthEnd(Date d)
public Date quarterBegin(Date d)
public Date yearBegin(Date d)
public Date yearEnd(Date d)
public Date yearToDate(int year)
public Date nextDay(Date d)
public Date addDays(Date date,
int n)
public Date nextWeek(Date d)
public Date nextMonth(Date d)
public Date nextQuarter(Date d)
public Date nextYear(Date d)
public Date previousDay(Date d)
public Date previousMonth(Date d)
public Date previousQuarter(Date d)
public Date previousYear(Date d)
public Date previousWeek(Date d)
public int weekInYear(Date d)
public int weekInMonth(Date d)
public int dayInMonth(Date d)
public int daysInMonth(Date d)
public int month(Date d)
public boolean isLastDayInMonth(Date d)
public int age(Date birthday)
public static Comparator<Date> createBirthdayComparator()
public int daysBetween(Date a,
Date b)
public int differenceInDays(Date a,
Date b)
public Date getDateForYear(int year)
public int y2k(int twoDigitYear)
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||