|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.text.Format
java.text.DateFormat
org.restlet.engine.util.InternetDateFormat
public class InternetDateFormat
This class handles Internet date/time strings in accordance with RFC 3339. It provides static methods to convert from various Java constructs (long, Date, and Calendar) to RFC 3339 format strings and to parse these strings back into the same Java constructs.
In addition to the static utility methods, this class also wraps a Calendar object allowing this class to be used as a value object in place of a Java construct.
Strings are parsed in accordance with the RFC 3339 format:
YYYY-MM-DD(T|t|\s)hh:mm:ss[.ddd][tzd]The
tzd
represents the time zone designator and is either an
upper or lower case 'Z' indicating UTC or a signed hh:mm
offset.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.text.DateFormat |
---|
DateFormat.Field |
Field Summary | |
---|---|
static TimeZone |
UTC
A time zone with zero offset and no DST. |
Fields inherited from class java.text.DateFormat |
---|
AM_PM_FIELD, calendar, DATE_FIELD, DAY_OF_WEEK_FIELD, DAY_OF_WEEK_IN_MONTH_FIELD, DAY_OF_YEAR_FIELD, DEFAULT, ERA_FIELD, FULL, HOUR_OF_DAY0_FIELD, HOUR_OF_DAY1_FIELD, HOUR0_FIELD, HOUR1_FIELD, LONG, MEDIUM, MILLISECOND_FIELD, MINUTE_FIELD, MONTH_FIELD, numberFormat, SECOND_FIELD, SHORT, TIMEZONE_FIELD, WEEK_OF_MONTH_FIELD, WEEK_OF_YEAR_FIELD, YEAR_FIELD |
Constructor Summary | |
---|---|
InternetDateFormat()
Creates a new InternetDateFormat object set to the current time using the UTC (Z) time zone. |
|
InternetDateFormat(Calendar cal)
Creates a new InternetDateFormat object initialized from a Calendar object. |
|
InternetDateFormat(Date date)
Creates a new InternetDateFormat object initialized from a Date object using the UTC (Z) time zone. |
|
InternetDateFormat(Date date,
TimeZone zone)
Creates a new InternetDateFormat object initialized from a Date object using the specified time zone. |
|
InternetDateFormat(long time)
Creates a new InternetDateFormat object initialized from a millisecond time value using the UTC (Z) time zone. |
|
InternetDateFormat(long time,
TimeZone zone)
Creates a new InternetDateFormat object initialized from a millisecond time value using the specified time zone. |
|
InternetDateFormat(String s)
Creates a new InternetDateFormat object by parsing an RFC 3339 date/time string. |
|
InternetDateFormat(TimeZone zone)
Creates a new InternetDateFormat object set to the current time using the specified time zone. |
Method Summary | |
---|---|
StringBuffer |
format(Date date,
StringBuffer toAppendTo,
FieldPosition fieldPosition)
|
Calendar |
getCalendar()
Gets the Calendar object wrapped by this InternetDateFormat object. |
Date |
getDate()
Gets the value of this InternetDateFormat object as a Date object. |
long |
getTime()
Gets the value of this InternetDateFormat object as millisecond time value. |
static String |
now()
Returns the current date and time as an RFC 3339 date/time string using the UTC (Z) time zone. |
static String |
now(TimeZone zone)
Returns the current date and time as an RFC 3339 date/time string using the specified time zone. |
Date |
parse(String source)
|
Date |
parse(String source,
ParsePosition pos)
|
static Calendar |
parseCalendar(String s)
Parses an RFC 3339 date/time string to a Calendar object. |
static Date |
parseDate(String s)
Parses an RFC 3339 date/time string to a Date object. |
static long |
parseTime(String s)
Parses an RFC 3339 date/time string to a millisecond time value. |
String |
toString()
Converts this InternetDateFormat object to an RFC 3339 date/time string. |
static String |
toString(Calendar cal)
Converts the specified Calendar object to an RFC 3339 date/time string. |
static String |
toString(Date date)
Converts the specified Date object to an RFC 3339 date/time string using the UTC (Z) time zone. |
static String |
toString(Date date,
TimeZone zone)
Converts the specified Date object to an RFC 3339 date/time string using the specified time zone. |
static String |
toString(long time)
Converts the specified millisecond time value to an RFC 3339 date/time string using the UTC (Z) time zone. |
static String |
toString(long time,
TimeZone zone)
Converts the specified millisecond time value to an RFC 3339 date/time string using the specified time zone. |
static InternetDateFormat |
valueOf(Date date)
Creates a new InternetDateFormat object from the specified Date object using the UTC (Z) time zone. |
static InternetDateFormat |
valueOf(Date date,
TimeZone zone)
Creates a new InternetDateFormat object from the specified Date object using the specified time zone. |
static InternetDateFormat |
valueOf(long time)
Creates a new InternetDateFormat object from the specified millisecond time value using the UTC (Z) time zone. |
static InternetDateFormat |
valueOf(long time,
TimeZone zone)
Creates a new InternetDateFormat object from the specified millisecond time value using the specified time zone. |
static InternetDateFormat |
valueOf(String s)
Creates a new InternetDateFormat object by parsing an RFC 3339 date/time string. |
Methods inherited from class java.text.DateFormat |
---|
clone, equals, format, format, getAvailableLocales, getDateInstance, getDateInstance, getDateInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getInstance, getNumberFormat, getTimeInstance, getTimeInstance, getTimeInstance, getTimeZone, hashCode, isLenient, parseObject, setCalendar, setLenient, setNumberFormat, setTimeZone |
Methods inherited from class java.text.Format |
---|
format, formatToCharacterIterator, parseObject |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final TimeZone UTC
Constructor Detail |
---|
public InternetDateFormat()
public InternetDateFormat(Calendar cal)
cal
- the Calendar objectpublic InternetDateFormat(Date date)
date
- the Date objectpublic InternetDateFormat(Date date, TimeZone zone)
date
- the Date objectzone
- the time zone to usepublic InternetDateFormat(long time)
time
- the millisecond time valuepublic InternetDateFormat(long time, TimeZone zone)
time
- the millisecond time valuezone
- the time zone to usepublic InternetDateFormat(String s)
s
- the string to parse
IllegalArgumentException
- if the string is not a valid RFC 3339 date/time stringpublic InternetDateFormat(TimeZone zone)
zone
- the time zone to useMethod Detail |
---|
public static String now()
public static String now(TimeZone zone)
zone
- the time zone to use
public static Calendar parseCalendar(String s)
s
- the string to parse
IllegalArgumentException
- if the string is not a valid RFC 3339 date/time stringpublic static Date parseDate(String s)
s
- the string to parse
IllegalArgumentException
- if the string is not a valid RFC 3339 date/time stringpublic static long parseTime(String s)
s
- the string to parse
IllegalArgumentException
- if the string is not a valid RFC 3339 date/time stringpublic static String toString(Calendar cal)
cal
- the Calendar object
public static String toString(Date date)
date
- the Date object
public static String toString(Date date, TimeZone zone)
date
- the Date objectzone
- the time zone to use
public static String toString(long time)
time
- the millisecond time value
public static String toString(long time, TimeZone zone)
time
- the millisecond time valuezone
- the time zone to use
public static InternetDateFormat valueOf(Date date)
date
- the Date object
public static InternetDateFormat valueOf(Date date, TimeZone zone)
date
- the Date objectzone
- the time zone to use
public static InternetDateFormat valueOf(long time)
time
- the millisecond time value
public static InternetDateFormat valueOf(long time, TimeZone zone)
time
- the millisecond time valuezone
- the time zone to use
public static InternetDateFormat valueOf(String s)
s
- the string to parse
IllegalArgumentException
- if the string is not a valid RFC 3339 date/time stringpublic StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition)
format
in class DateFormat
public Calendar getCalendar()
getCalendar
in class DateFormat
public Date getDate()
public long getTime()
public Date parse(String source) throws ParseException
parse
in class DateFormat
ParseException
public Date parse(String source, ParsePosition pos)
parse
in class DateFormat
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |