|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jboss.dna.common.util.DateUtil
@ThreadSafe public class DateUtil
Utilities for working with dates.
Many of the methods that convert dates to and from strings utilize the ISO
8601:2004 standard string format yyyy-MM-ddTHH:mm:ss.SSSZ, where
Symbol Meaning Presentation Example ------ ------- ------------ ------- y year (Number) 1996 M month in year (Number) 07 d day in month (Number) 10 h hour in am/pm (1˜12) (Number) 12 H hour in day (0˜23) (Number) 0 m minute in hour (Number) 30 s second in minute (Number) 55 S millisecond (Number) 978 Z time zone (Number) -0600
This class is written to be thread safe. As SimpleDateFormat is not threadsafe, no shared instances are used.
| Field Summary | |
|---|---|
static java.lang.String |
ISO_8601_2004_FORMAT
|
| Method Summary | |
|---|---|
static java.util.Calendar |
getCalendarFromStandardString(java.lang.String dateString)
Parse the date contained in the supplied string. |
static java.lang.String |
getDateAsStandardString(java.util.Calendar date)
Obtain an ISO 8601:2004 string representation of the date given the supplied milliseconds since the epoch. |
static java.lang.String |
getDateAsStandardString(java.util.Date date)
Obtain an ISO 8601:2004 string representation of the supplied date. |
static java.lang.String |
getDateAsStandardString(long millisecondsSinceEpoch)
Obtain an ISO 8601:2004 string representation of the date given the supplied milliseconds since the epoch. |
static java.lang.String |
getDateAsStringForCurrentLocale(java.util.Date date)
|
static java.lang.String |
getDateAsStringForLocale(java.util.Date date,
java.util.Locale locale)
|
static java.util.Date |
getDateFromStandardString(java.lang.String dateString)
Parse the date contained in the supplied string. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String ISO_8601_2004_FORMAT
| Method Detail |
|---|
public static java.util.Calendar getCalendarFromStandardString(java.lang.String dateString)
throws java.text.ParseException
datepartTtimepart, where datepart is one of the following forms:
The timepart consists of one of the following forms that contain the 2-digit hour (00-24), the
2-digit minutes (00-59), the 2-digit seconds (00-59), and the 1-to-3 digit milliseconds. The minutes, seconds and
milliseconds are optional, but any component is required if it is followed by another component (e.g., minutes are required
if the seconds are given).
followed by one of the following time zone definitions:
dateString - the string containing the date to be parsed
Calendar object.
java.text.ParseException - if there is a problem parsing the string
public static java.util.Date getDateFromStandardString(java.lang.String dateString)
throws java.text.ParseException
Calendar.getTime() on the result of
getCalendarFromStandardString(String).
dateString - the string containing the date to be parsed
Calendar object.
java.text.ParseException - if there is a problem parsing the stringgetCalendarFromStandardString(String)public static java.lang.String getDateAsStandardString(long millisecondsSinceEpoch)
millisecondsSinceEpoch - the milliseconds for the date
standard formatgetDateAsStandardString(Date),
getDateFromStandardString(String),
getCalendarFromStandardString(String)public static java.lang.String getDateAsStandardString(java.util.Calendar date)
date - the date in calendar form
standard formatgetDateAsStandardString(Date),
getDateFromStandardString(String),
getCalendarFromStandardString(String)public static java.lang.String getDateAsStandardString(java.util.Date date)
date - the date
standard formatgetDateAsStandardString(long),
getDateFromStandardString(String),
getCalendarFromStandardString(String)public static java.lang.String getDateAsStringForCurrentLocale(java.util.Date date)
public static java.lang.String getDateAsStringForLocale(java.util.Date date,
java.util.Locale locale)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||