|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.stratelia.webactiv.util.DateUtil
public class DateUtil
DateUtil is an helper class for date manipulation.
Field Summary | |
---|---|
static org.apache.commons.lang3.time.FastDateFormat |
DATE_FORMATTER
|
static SimpleDateFormat |
DATE_PARSER
Format and parse dates. |
static org.apache.commons.lang3.time.FastDateFormat |
DATETIME_FORMATTER
|
static SimpleDateFormat |
DATETIME_PARSER
|
static org.apache.commons.lang3.time.FastDateFormat |
ICALDATE_FORMATTER
|
static org.apache.commons.lang3.time.FastDateFormat |
ICALDAY_FORMATTER
|
static org.apache.commons.lang3.time.FastDateFormat |
ICALUTCDATE_FORMATTER
|
static org.apache.commons.lang3.time.FastDateFormat |
ISO8601_FORMATTER
|
static org.apache.commons.lang3.time.FastDateFormat |
ISO8601DATE_FORMATTER
|
static org.apache.commons.lang3.time.FastDateFormat |
ISO8601DAY_FORMATTER
|
static Date |
MAXIMUM_DATE
|
static Date |
MINIMUM_DATE
|
static org.apache.commons.lang3.time.FastDateFormat |
TIME_FORMATTER
|
static SimpleDateFormat |
TIME_PARSER
Format and parse dates. |
Method Summary | |
---|---|
static void |
addDaysExceptWeekEnds(Calendar calendar,
int nbDay)
Compute a new date by adding the specified number of days without couting week-ends. |
static Datable<?> |
asDatable(Date aDate,
boolean withTime)
Converts the specified date as a Datable object with the time set or not. |
static int |
compareTo(Date date1,
Date date2)
Compare 2 dates on year/month/day only. |
static int |
compareTo(Date date1,
Date aDate2,
boolean aForceResetHour)
Compare 2 dates. |
static Calendar |
convert(Date curDate)
Convert Date to Calendar |
static Calendar |
convert(Date curDate,
String language)
Convert Date to Calendar |
static String |
date2SQLDate(Date date)
|
static String |
date2SQLDate(String date,
String language)
|
static boolean |
datesAreEqual(Date date1,
Date date2)
Test if two dates are equal |
static String |
dateToString(Date date,
String language)
Display the date in a language specific standard format. |
static int |
extractHour(String hour)
|
static int |
extractMinutes(String hour)
|
static String |
firstDayOfMonth2SQLDate(Date date)
Returns the first date of month according to given date (ex. 26/08/2010) |
static String |
formatAsICalDate(Date date)
Formats the specified date according to the ISO 8601 format of the iCal format (in the timezone of the date). |
static String |
formatAsICalDay(Date date)
Formats the specified date according to the short ISO 8601 format (only the day date is rendered) used in the iCal format. |
static String |
formatAsICalUTCDate(Date date)
Formats the specified date according to the ISO 8601 format of the iCal format (in UTC). |
static String |
formatAsISO8601Date(Date date)
Formats the specified date according to the ISO 8601 format. |
static String |
formatAsISO8601Day(Date date)
Formats the specified date according to the short ISO 8601 format (only the day date is rendered). |
static String |
formatDate(Calendar calend)
Format a Calendar to a String of format yyyy/MM/dd. |
static String |
formatDate(Date date)
Format a Date to a String of format yyyy/MM/dd. |
static String |
formatDate(Date date,
String pattern)
Formats the specified date according to the specified date pattern. |
static String |
formatDuration(long duration)
|
static String |
formatTime(Calendar calend)
Format a Calendar to a String of format HH:mm. |
static String |
formatTime(Date date)
Format a Date to a String of format HH:mm. |
static Date |
getBeginOfDay(Date curDate)
Get first hour, minute, second, millisecond of the specified date |
static Date |
getDate()
Gets the current date with reseted hour. |
static Date |
getDate(Date date,
String hour)
|
static SimpleDateFormat |
getDateAndHourInputFormat(String lang)
Get the date language specific standard input format. |
static SimpleDateFormat |
getDateInputFormat(String language)
Get the date language specific standard input format. |
static org.apache.commons.lang3.time.FastDateFormat |
getDateOutputFormat(String lang)
Get the date language specific standard output format. |
static int |
getDayNumberBetween(Date date1,
Date date2)
Get the number of days between two dates. |
static int |
getDayNumberInWeek(Date curDate)
Return the day index of the week from a given date. |
static Date |
getEndDateOfMonth(Date date)
Compute the date of the last day in the month of the specified date. |
static Date |
getEndDateOfWeek(Date date,
String language)
Compute the date of the last day in the week of the specified date. |
static Date |
getEndDateOfYear(Date date)
Compute the date of the last day in the year of the specified date. |
static Date |
getEndOfDay(Date curDate)
Get last hour, minute, second, millisecond of the specified date |
static Date |
getFirstDateOfMonth(Date date)
Compute the date of the first day in the month of the specified date. |
static Date |
getFirstDateOfWeek(Date date,
String language)
Compute the date of the first day in the week of the specified date. |
static Date |
getFirstDateOfYear(Date date)
Compute the date of the first day in the year of the specified date. |
static int |
getFirstDayOfWeek(String language)
Gets the first day of weeks of the calendar with 1 meaning for sunday, 2 meaning for monday, and so on. |
static String |
getFormattedTime(Date date)
|
static SimpleDateFormat |
getHourInputFormat(String language)
Get the hour (from a date) language specific standard input format. |
static org.apache.commons.lang3.time.FastDateFormat |
getHourOutputFormat(String lang)
Get the hour (from a date) language specific standard output format. |
static String |
getInputDate(Date date,
String language)
|
static String |
getInputDate(String dateDB,
String language)
|
static ResourceLocator |
getMultilangProperties(String language)
Get all date multilang properties. |
static Date |
getNow()
Gets the current date and hour. |
static String |
getOutputDate(Date date,
String language)
|
static String |
getOutputDate(String dateDB,
String language)
|
static String |
getOutputDateAndHour(Date date,
String language)
|
static String |
getOutputDateAndHour(String dateDB,
String language)
|
static String |
getOutputHour(Date date,
String language)
|
static String |
getOutputHour(String dateDB,
String language)
|
static Date |
parse(String date)
Parse a special String into a Date. |
static Date |
parse(String date,
String format)
Parse a special String into a Date. |
static Calendar |
parseCalendar(String date)
Parse a String of format yyyy/MM/dd and return the corresponding Date. |
static Date |
parseDate(String date)
Parse a String of format yyyy/MM/dd and return the corresponding Date. |
static Date |
parseDateTime(String date)
Parse a String of format yyyy/MM/dd hh:mm and return the corresponding Date. |
static Date |
parseISO8601Date(String date)
Parses the specified ISO 8601 formatted date and returns it as a Date instance. |
static Date |
parseTime(String time)
Parse a String of format yyyy/MM/dd hh:mm and return the corresponding Date. |
static Calendar |
resetHour(Calendar date)
Reset hour of a date (00:00:00.000) |
static Date |
resetHour(Date date)
Reset hour of a date (00:00:00.000) |
static void |
setAtBeginOfDay(Calendar calendar)
Set the first hour, minute, second, millisecond of the specified calendar to 0. |
static void |
setTime(Calendar calend,
String time)
Parse a String of format HH:mm and set the corresponding hours and minutes to the specified Calendar. |
static Date |
stringToDate(String string,
String language)
Parse the date in a language specific standard format. |
static Date |
stringToDate(String date,
String hour,
String language)
|
static String |
today2SQLDate()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Date MINIMUM_DATE
public static final Date MAXIMUM_DATE
public static final SimpleDateFormat DATE_PARSER
public static final org.apache.commons.lang3.time.FastDateFormat DATE_FORMATTER
public static final SimpleDateFormat DATETIME_PARSER
public static final org.apache.commons.lang3.time.FastDateFormat DATETIME_FORMATTER
public static final org.apache.commons.lang3.time.FastDateFormat ISO8601DATE_FORMATTER
public static final org.apache.commons.lang3.time.FastDateFormat ISO8601DAY_FORMATTER
public static final org.apache.commons.lang3.time.FastDateFormat ICALDAY_FORMATTER
public static final org.apache.commons.lang3.time.FastDateFormat ICALDATE_FORMATTER
public static final org.apache.commons.lang3.time.FastDateFormat ICALUTCDATE_FORMATTER
public static final org.apache.commons.lang3.time.FastDateFormat ISO8601_FORMATTER
public static final SimpleDateFormat TIME_PARSER
public static final org.apache.commons.lang3.time.FastDateFormat TIME_FORMATTER
Method Detail |
---|
public static String dateToString(Date date, String language)
date
- the date to convert.language
- The current user's language
public static String getOutputDate(Date date, String language)
public static String getOutputDate(String dateDB, String language) throws ParseException
ParseException
public static String getOutputHour(Date date, String language)
public static String getOutputHour(String dateDB, String language) throws ParseException
ParseException
public static String getOutputDateAndHour(String dateDB, String language) throws ParseException
ParseException
public static String getOutputDateAndHour(Date date, String language)
public static String getInputDate(Date date, String language)
public static String getInputDate(String dateDB, String language) throws ParseException
ParseException
public static Date stringToDate(String string, String language) throws ParseException
string
- The String to convert in Datelanguage
- The current user's language
ParseException
- if the input String is null, empty, or just in an incorrect
format.public static Date stringToDate(String date, String hour, String language) throws ParseException
ParseException
public static Date getNow()
public static Date getDate()
public static Date getDate(Date date, String hour)
public static int extractHour(String hour)
public static int extractMinutes(String hour)
public static org.apache.commons.lang3.time.FastDateFormat getDateOutputFormat(String lang)
lang
- The current user's language
public static SimpleDateFormat getDateInputFormat(String language)
language
- The current user's language
public static org.apache.commons.lang3.time.FastDateFormat getHourOutputFormat(String lang)
lang
- The current user's language
public static SimpleDateFormat getHourInputFormat(String language)
language
- The current user's language
public static SimpleDateFormat getDateAndHourInputFormat(String lang)
lang
- The current user's language
public static ResourceLocator getMultilangProperties(String language)
language
- The current user's language.
public static Date parse(String date) throws ParseException
date
- (String) the format of this date must be yyyy/MM/dd
ParseException
public static Date parse(String date, String format) throws ParseException
date
- (String) the format of this date must be yyyy/MM/ddformat
- (String) the whished format in according to the date parameter
ParseException
public static boolean datesAreEqual(Date date1, Date date2)
date1
- first datedate2
- second date
public static int compareTo(Date date1, Date date2)
date1
- date2
-
public static int compareTo(Date date1, Date aDate2, boolean aForceResetHour)
date1
- aDate2
-
public static String today2SQLDate()
public static String date2SQLDate(Date date)
date
- the date to transform
public static String date2SQLDate(String date, String language) throws ParseException
ParseException
public static String firstDayOfMonth2SQLDate(Date date)
date
- any date
public static String formatDuration(long duration)
public static String getFormattedTime(Date date)
public static Date parseDate(String date) throws ParseException
date
- the String to be parsed.
ParseException
public static Calendar resetHour(Calendar date)
date
-
public static Date resetHour(Date date)
date
-
public static Date parseDateTime(String date) throws ParseException
date
- the String to be parsed.
ParseException
public static Date parseTime(String time) throws ParseException
time
- the String to be parsed.
ParseException
public static Calendar parseCalendar(String date) throws ParseException
date
- the String to be parsed.
ParseException
public static String formatDate(Date date)
date
- the date to be formatted.
public static String formatDate(Calendar calend)
calend
- the date to be formatted.
public static String formatDate(Date date, String pattern)
date
- the date to format into a string.pattern
- the pattern to apply in the format.
public static void setTime(Calendar calend, String time)
time
- the String to be parsed.calend
- the calendar to be updated.public static String formatTime(Date date)
date
- the date to be formatted.
public static String formatTime(Calendar calend)
calend
- the date to be formatted.
public static String formatAsISO8601Date(Date date)
date
- the date to format.
public static String formatAsISO8601Day(Date date)
date
- the date to format.
public static String formatAsICalDate(Date date)
date
- the date to format.
public static String formatAsICalUTCDate(Date date)
date
- the date to format.
public static String formatAsICalDay(Date date)
date
- the date to format.
public static Date parseISO8601Date(String date) throws ParseException
date
- the date to parse (must satisfy one of the following pattern yyyy-MM-ddTHH:mm or
yyyy-MM-dd).
ParseException
- if the specified date is not in the one of the expected formats.public static Datable<?> asDatable(Date aDate, boolean withTime)
aDate
- a Java date to convert.withTime
- the time in the Java date has to be taken into account.
public static Date getFirstDateOfYear(Date date)
date
- the specified date.
public static Date getEndDateOfYear(Date date)
date
- the specified date.
public static Date getFirstDateOfMonth(Date date)
date
- the specified date.
public static Date getEndDateOfMonth(Date date)
date
- the specified date.
public static Date getFirstDateOfWeek(Date date, String language)
date
- the specified date.language
- the locale to take into account (fr for the french locale (fr_FR) for
example).
public static Date getEndDateOfWeek(Date date, String language)
date
- the specified date.language
- the locale to take into account (fr for the french locale (fr_FR) for
example).
public static int getFirstDayOfWeek(String language)
language
- the locale to take into account (fr for the french locale (fr_FR) for
example).
public static Date getEndOfDay(Date curDate)
curDate
- the specified date
public static Date getBeginOfDay(Date curDate)
curDate
- the specified date
public static void setAtBeginOfDay(Calendar calendar)
calendar
- the specified calendar.public static void addDaysExceptWeekEnds(Calendar calendar, int nbDay)
calendar
- nbDay
- public static int getDayNumberInWeek(Date curDate)
curDate
-
public static int getDayNumberBetween(Date date1, Date date2)
date1
- date2
-
public static Calendar convert(Date curDate)
curDate
-
public static Calendar convert(Date curDate, String language)
curDate
- language
- the locale to take into account (fr for the french locale (fr_FR) for
example).
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |