|
||||||||||
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.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 |
---|
java.text.DateFormat.Field |
Field Summary | |
---|---|
static java.util.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(java.util.Calendar cal)
Creates a new InternetDateFormat object initialized from a Calendar object. |
|
InternetDateFormat(java.util.Date date)
Creates a new InternetDateFormat object initialized from a Date object using the UTC (Z) time zone. |
|
InternetDateFormat(java.util.Date date,
java.util.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,
java.util.TimeZone zone)
Creates a new InternetDateFormat object initialized from a millisecond time value using the specified time zone. |
|
InternetDateFormat(java.lang.String s)
Creates a new InternetDateFormat object by parsing an RFC 3339 date/time string. |
|
InternetDateFormat(java.util.TimeZone zone)
Creates a new InternetDateFormat object set to the current time using the specified time zone. |
Method Summary | |
---|---|
java.lang.StringBuffer |
format(java.util.Date date,
java.lang.StringBuffer toAppendTo,
java.text.FieldPosition fieldPosition)
|
java.util.Calendar |
getCalendar()
Gets the Calendar object wrapped by this InternetDateFormat object. |
java.util.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 java.lang.String |
now()
Returns the current date and time as an RFC 3339 date/time string using the UTC (Z) time zone. |
static java.lang.String |
now(java.util.TimeZone zone)
Returns the current date and time as an RFC 3339 date/time string using the specified time zone. |
java.util.Date |
parse(java.lang.String source)
|
java.util.Date |
parse(java.lang.String source,
java.text.ParsePosition pos)
|
static java.util.Calendar |
parseCalendar(java.lang.String s)
Parses an RFC 3339 date/time string to a Calendar object. |
static java.util.Date |
parseDate(java.lang.String s)
Parses an RFC 3339 date/time string to a Date object. |
static long |
parseTime(java.lang.String s)
Parses an RFC 3339 date/time string to a millisecond time value. |
java.lang.String |
toString()
Converts this InternetDateFormat object to an RFC 3339 date/time string. |
static java.lang.String |
toString(java.util.Calendar cal)
Converts the specified Calendar object to an RFC 3339 date/time string. |
static java.lang.String |
toString(java.util.Date date)
Converts the specified Date object to an RFC 3339 date/time string using the UTC (Z) time zone. |
static java.lang.String |
toString(java.util.Date date,
java.util.TimeZone zone)
Converts the specified Date object to an RFC 3339 date/time string using the specified time zone. |
static java.lang.String |
toString(long time)
Converts the specified millisecond time value to an RFC 3339 date/time string using the UTC (Z) time zone. |
static java.lang.String |
toString(long time,
java.util.TimeZone zone)
Converts the specified millisecond time value to an RFC 3339 date/time string using the specified time zone. |
static InternetDateFormat |
valueOf(java.util.Date date)
Creates a new InternetDateFormat object from the specified Date object using the UTC (Z) time zone. |
static InternetDateFormat |
valueOf(java.util.Date date,
java.util.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,
java.util.TimeZone zone)
Creates a new InternetDateFormat object from the specified millisecond time value using the specified time zone. |
static InternetDateFormat |
valueOf(java.lang.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 java.util.TimeZone UTC
Constructor Detail |
---|
public InternetDateFormat()
public InternetDateFormat(java.util.Calendar cal)
cal
- the Calendar objectpublic InternetDateFormat(java.util.Date date)
date
- the Date objectpublic InternetDateFormat(java.util.Date date, java.util.TimeZone zone)
date
- the Date objectzone
- the time zone to usepublic InternetDateFormat(long time)
time
- the millisecond time valuepublic InternetDateFormat(long time, java.util.TimeZone zone)
time
- the millisecond time valuezone
- the time zone to usepublic InternetDateFormat(java.lang.String s)
s
- the string to parse
java.lang.IllegalArgumentException
- if the string is not a valid RFC 3339 date/time stringpublic InternetDateFormat(java.util.TimeZone zone)
zone
- the time zone to useMethod Detail |
---|
public static java.lang.String now()
public static java.lang.String now(java.util.TimeZone zone)
zone
- the time zone to use
public static java.util.Calendar parseCalendar(java.lang.String s)
s
- the string to parse
java.lang.IllegalArgumentException
- if the string is not a valid RFC 3339 date/time stringpublic static java.util.Date parseDate(java.lang.String s)
s
- the string to parse
java.lang.IllegalArgumentException
- if the string is not a valid RFC 3339 date/time stringpublic static long parseTime(java.lang.String s)
s
- the string to parse
java.lang.IllegalArgumentException
- if the string is not a valid RFC 3339 date/time stringpublic static java.lang.String toString(java.util.Calendar cal)
cal
- the Calendar object
public static java.lang.String toString(java.util.Date date)
date
- the Date object
public static java.lang.String toString(java.util.Date date, java.util.TimeZone zone)
date
- the Date objectzone
- the time zone to use
public static java.lang.String toString(long time)
time
- the millisecond time value
public static java.lang.String toString(long time, java.util.TimeZone zone)
time
- the millisecond time valuezone
- the time zone to use
public static InternetDateFormat valueOf(java.util.Date date)
date
- the Date object
public static InternetDateFormat valueOf(java.util.Date date, java.util.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, java.util.TimeZone zone)
time
- the millisecond time valuezone
- the time zone to use
public static InternetDateFormat valueOf(java.lang.String s)
s
- the string to parse
java.lang.IllegalArgumentException
- if the string is not a valid RFC 3339 date/time stringpublic java.lang.StringBuffer format(java.util.Date date, java.lang.StringBuffer toAppendTo, java.text.FieldPosition fieldPosition)
format
in class java.text.DateFormat
public java.util.Calendar getCalendar()
getCalendar
in class java.text.DateFormat
public java.util.Date getDate()
public long getTime()
public java.util.Date parse(java.lang.String source) throws java.text.ParseException
parse
in class java.text.DateFormat
java.text.ParseException
public java.util.Date parse(java.lang.String source, java.text.ParsePosition pos)
parse
in class java.text.DateFormat
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |