public class FastDateFormat
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
FastDateFormat.FormatSpec
Specification of how to format a date.
|
| Constructor and Description |
|---|
FastDateFormat(FastDateFormat.FormatSpec formatSpec,
java.util.TimeZone zone)
Constructs a FastDateFormat using the specified default format spec and the specified time zone, or UTC if given null.
|
FastDateFormat(java.util.TimeZone zone)
Constructs a FastDateFormat using the specified time zone, or UTC if given null.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
format(FastDateFormat.FormatSpec formatSpec,
long time)
Formats a given time in a profile of ISO8601.
|
java.lang.String |
format(FastDateFormat.FormatSpec formatSpec,
long time,
boolean isNow)
Formats a given time in a profile of ISO8601.
|
static java.lang.String |
format(FastDateFormat.FormatSpec formatSpec,
long time,
java.util.TimeZone zone)
Formats a given time in a profile of ISO8601, using a specified time zone.
|
java.lang.String |
format(long time)
Formats a given time using the default format spec.
|
java.lang.String |
format(long time,
boolean isNow)
Formats a given time using the default format spec.
|
static java.lang.String |
format(long time,
java.util.TimeZone zone)
Formats a given time in the default format spec (2012-11-02T23:39:05.346-05:00), using a specified time zone.
|
java.lang.String |
formatNow()
Formats the current time using the default format spec, caching format calculations for increased performance over many calls.
|
java.lang.String |
formatNow(FastDateFormat.FormatSpec formatSpec)
Formats the current time in a profile of ISO8601, caching format calculations for increased performance over many calls.
|
static java.lang.String |
formatUtc(FastDateFormat.FormatSpec formatSpec,
long time)
Formats a given time in a profile of ISO8601, using UTC.
|
static java.lang.String |
formatUtc(long time)
Formats a given time in the default format spec (2012-11-02T23:39:05.346Z), using UTC.
|
static FastDateFormat |
getLocalFormat()
Returns a FastDateFormat which uses the local time zone, TimeZone.getDefault().
|
static FastDateFormat |
getUtcFormat()
Returns a FastDateFormat which uses UTC.
|
static void |
main(java.lang.String[] args) |
long |
parse(java.lang.String dateString)
Parses a date representation which is generally ISO8601-compliant into milliseconds since the epoch.
|
static long |
parse(java.lang.String dateString,
java.util.TimeZone zone)
Parses a date representation which is generally ISO8601-compliant into milliseconds since the epoch, using a given time zone if the time zone is not explicit in the input.
|
static long |
parseUtc(java.lang.String dateString)
Parses a date representation which is generally ISO8601-compliant into milliseconds since the epoch, assuming UTC if the time zone is not explicit in the input.
|
public FastDateFormat(java.util.TimeZone zone)
FastDateFormat.FormatSpec.ISO8601_MS.
For UTC and the default time zone, prefer getUtcFormat() and getLocalFormat().zone - a TimeZone object, or null to use UTC.public FastDateFormat(FastDateFormat.FormatSpec formatSpec, java.util.TimeZone zone)
getUtcFormat() and getLocalFormat().formatSpec - a FastDateFormat.FormatSpec specifying the default formattingzone - a TimeZone object, or null to use UTC.public java.lang.String formatNow()
public java.lang.String format(long time)
time - the time to format.public java.lang.String format(long time,
boolean isNow)
time - the time to format.isNow - whether to cache formatting information over multiple calls. Should be set true when consecutive calls are close in time.public java.lang.String formatNow(FastDateFormat.FormatSpec formatSpec)
formatSpec - specification of how to format.public java.lang.String format(FastDateFormat.FormatSpec formatSpec, long time)
formatSpec - specification of how to format.time - the time to format.public java.lang.String format(FastDateFormat.FormatSpec formatSpec, long time, boolean isNow)
formatSpec - specification of how to format.time - the time to format.isNow - whether to cache formatting information over multiple calls. Should be set true when consecutive calls are close in time.public static java.lang.String formatUtc(long time)
time - the time to format.public static java.lang.String format(long time,
java.util.TimeZone zone)
time - the time to format.zone - the time zone for the formatting.public static java.lang.String formatUtc(FastDateFormat.FormatSpec formatSpec, long time)
formatSpec - specification of how to format.time - the time to format.public static java.lang.String format(FastDateFormat.FormatSpec formatSpec, long time, java.util.TimeZone zone)
formatSpec - specification of how to format.time - the time to format.zone - the time zone for the formatting.public static FastDateFormat getUtcFormat()
public static FastDateFormat getLocalFormat()
public static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exceptionpublic long parse(java.lang.String dateString)
throws java.text.ParseException
dateString - the date to be parsed.java.text.ParseException - if the date can not be parsed.public static long parseUtc(java.lang.String dateString)
throws java.text.ParseException
dateString - the date to be parsed.java.text.ParseException - if the date can not be parsed.public static long parse(java.lang.String dateString,
java.util.TimeZone zone)
throws java.text.ParseException
dateString - the date to be parsed.zone - the time zone of the date if an explicit time zone is not given in the input.java.text.ParseException - if the date can not be parsed.