|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.day.cq.commons.date.DateUtil
public class DateUtil
DateUtil is a utility class that provides easy access to
commonly used dates and for parsing/reading ISO8601 date strings.
| Constructor Summary | |
|---|---|
DateUtil()
Initializes a DateUtil with the first day of week being the Monday. |
|
DateUtil(int firstDayOfWeek)
Initializes a DateUtil with a custom first day of the week. |
|
| Method Summary | |
|---|---|
static String |
getISO8601Date(Calendar calendar)
Generate a full ISO 8601 date: "YYYY-MM-DDTHH:mm:ss.SSSZ". |
static String |
getISO8601Date(Date date)
Generate a full ISO 8601 date: "YYYY-MM-DDTHH:mm:ss.SSSZ". |
static String |
getISO8601Date(Date date,
TimeZone timeZone)
Generate a full ISO 8601 date: "YYYY-MM-DDTHH:mm:ss.SSSZ". |
static String |
getISO8601DateAndTimeNoMillis(Calendar calendar)
Generate a ISO 8601 date with date and time, but without the milliseconds part: "YYYY-MM-DDTHH:mm:ssZ". |
static String |
getISO8601DateAndTimeNoMillis(Date date)
Generate a ISO 8601 date with date and time, but without the milliseconds part: "YYYY-MM-DDTHH:mm:ssZ". |
static String |
getISO8601DateAndTimeNoMillis(Date date,
TimeZone timeZone)
Generate a ISO 8601 date with date and time, but without the milliseconds part: "YYYY-MM-DDTHH:mm:ssZ". |
static String |
getISO8601DateNoTime(Calendar calendar)
Generate a ISO 8601 date in the pure date form: "YYYY-MM-DD" |
static String |
getISO8601DateNoTime(Date date)
Generate a ISO 8601 date in the pure date form: "YYYY-MM-DD". |
static String |
getISO8601DateNoTime(Date date,
TimeZone timeZone)
Generate a ISO 8601 date in the pure date form: "YYYY-MM-DD". |
Calendar |
getLastYearStart()
|
Calendar |
getMonthStart()
|
Calendar |
getNow()
|
Calendar |
getThreeMonthsAgo()
|
Calendar |
getToday()
|
Calendar |
getWeekStart()
|
Calendar |
getYearStart()
|
static Calendar |
parseISO8601(String iso8601Date)
Parse the given string in ISO 8601 format and build a Calendar object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DateUtil()
public DateUtil(int firstDayOfWeek)
firstDayOfWeek - the first day of the week.Calendar.DAY_OF_WEEK| Method Detail |
|---|
public final Calendar getLastYearStart()
public final Calendar getYearStart()
public final Calendar getThreeMonthsAgo()
public final Calendar getMonthStart()
public final Calendar getWeekStart()
#setFirstDayOfWeek(int)!public final Calendar getToday()
public final Calendar getNow()
public static Calendar parseISO8601(String iso8601Date)
throws InvalidDateException
iso8601Date - the date in ISO 8601 format
InvalidDateException - if the date string is not validpublic static String getISO8601Date(Calendar calendar)
calendar - a Calendar instance
public static String getISO8601Date(Date date)
date - a Date instance representing a UTC time
public static String getISO8601Date(Date date,
TimeZone timeZone)
date - a Date instancetimeZone - the timeZone of the date
public static String getISO8601DateAndTimeNoMillis(Calendar calendar)
calendar - a Calendar instance
public static String getISO8601DateAndTimeNoMillis(Date date)
date - a Date instance representing a UTC time
public static String getISO8601DateAndTimeNoMillis(Date date,
TimeZone timeZone)
date - a Date instancetimeZone - the timeZone of the date
public static String getISO8601DateNoTime(Calendar calendar)
calendar - a Calendar instance
public static String getISO8601DateNoTime(Date date)
date - a Date instance representing a UTC time.
public static String getISO8601DateNoTime(Date date,
TimeZone timeZone)
date - a Date instance representing a datetimeZone - the timeZone of the date
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||