public final class UtlTime extends Object
This class IS supported for use by end users.
| Constructor and Description |
|---|
UtlTime() |
| Modifier and Type | Method and Description |
|---|---|
static void |
cleanupFormatter()
Cleans up the calling thread's
ThreadLocal DateFormat |
static String |
format(Date date)
Formats the given date using the current default timestamp format via
a
ThreadLocal DateFormat instance. |
static DateFormat |
getCachedTimestampFormatter()
Get's the thread local cached, timestamp formatter with the
current timestamp formatting settings.
|
static String |
getTimestampFormat()
Returns the current default timestamp format string
|
static DateFormat |
getTimestampFormatter()
Constructs a new DateFormat using the
getTimestampFormat()
and dateFormatTimeZone. |
static TimeZone |
getTimestampFormatTimeZone()
Returns the current default timestamp format string
|
static boolean |
isNativeTimeEnabled() |
static void |
main(String[] args)
Prints the current time, suffixed with microseconds.
|
static long |
now()
Return the current time, in nanoseconds
|
static long |
nowInMicros()
Return the current time, in microseconds.
|
static long |
nowInMillis()
Return the current time, in millseconds.
|
static Date |
parse(String timestamp)
Attempts to parse the provide timestamp as a Date using the current
timezone format.
|
static void |
setTimestampFormat(String dateFormat)
Sets the default timestamp format which is used by various platform components.
|
static TimeZone |
setTimestampFormatTimeZone(String timezone)
Sets the default date format timezone which is used by various platform components
Note, that this will not affect components that have already retrieved the a
dateformat unless those components resample the timezoneFormat
This method looks up the timezone using
TimeZone.getTimeZone(String) which
will default the timezone to 'GMT' if the given timezone is not valid. |
static void |
setTimestampFormatTimeZone(TimeZone timezone)
Sets the default date format timezone which is used by various platform components
Note, that this will not affect components that have already retrieved the a
dateformat unless those components resample the timezoneFormat
|
public static final boolean isNativeTimeEnabled()
public static final long now()
public static final long nowInMicros()
public static final long nowInMillis()
public static final void setTimestampFormat(String dateFormat)
dateFormat - The date format to be used by getTimestampFormatter()IllegalArgumentException - if the dateFormat is not validpublic static final String getTimestampFormat()
public static final void setTimestampFormatTimeZone(TimeZone timezone)
timezone - The time zone to be used by getTimestampFormat()public static final TimeZone setTimestampFormatTimeZone(String timezone)
This method looks up the timezone using TimeZone.getTimeZone(String) which
will default the timezone to 'GMT' if the given timezone is not valid.
timezone - The time zone to be used by getTimestampFormatter()TimeZone that was set.public static final TimeZone getTimestampFormatTimeZone()
public static final DateFormat getTimestampFormatter()
getTimestampFormat()
and dateFormatTimeZone.public static final String format(Date date)
ThreadLocal DateFormat instance. Callers of this mehod
should call cleanupFormatter() before the the calling thread
is stopped.date - The date to format.public static final Date parse(String timestamp) throws ParseException
timestamp - The timestamp to parseParseException - if there is an error parsing the timestamppublic static final DateFormat getCachedTimestampFormatter()
public static final void cleanupFormatter()
ThreadLocal DateFormatpublic static final void main(String[] args)
args - Argumens (unused).Copyright © 2019 N5 Technologies, Inc. All Rights Reserved.