public class Currently
extends java.lang.Object
Date
,
SimpleDateFormat
Modifier and Type | Field and Description |
---|---|
private static java.lang.String[] |
c_expression
Store the regular expressions necessary to parse ISO timestamps.
|
private static java.util.regex.Pattern[] |
c_pattern
Stores compiled patterns at first use, quasi-Singleton.
|
static java.lang.String |
DEFAULT_FORMAT
Default time format, which is compact and has a timezone
|
private java.text.SimpleDateFormat |
m_formatter
This is used to format the time stamp.
|
Constructor and Description |
---|
Currently()
Default ctor: Create a new instance with a default formatting
string for timestamps.
|
Currently(java.text.SimpleDateFormat format)
Ctor: Create a new instance with a formatting string for time stamps.
|
Currently(java.lang.String formatString)
Ctor: Create a new instance with a formatting string for time stamps.
|
Modifier and Type | Method and Description |
---|---|
java.text.SimpleDateFormat |
getDateFormat()
Accessor: Obtains the default timestamp format for all queues.
|
static java.lang.String |
iso8601(boolean zuluTime)
Ignores any internal date format, and tries to show a complete
date/timp stamp of the current time in extended ISO 8601 format.
|
static java.lang.String |
iso8601(boolean zuluTime,
boolean extendedFormat,
boolean withMillis,
java.util.Date now)
Ignores any internal date format, and tries to show a complete
date/timp stamp in extended ISO 8601 format.
|
java.lang.String |
now()
Obtains the current time as formatted string according to
the format option.
|
java.lang.String |
now(java.util.Date then)
Obtains the current time as formatted string according to
the format option.
|
static java.util.Date |
parse(java.lang.String stamp)
Parses one of the ISO 8601 that it produces.
|
void |
setDateFormat(java.text.SimpleDateFormat format)
Accessor: Sets the default timestamp format for all queues.
|
void |
setDateFormat(java.lang.String format)
Accessor: Sets the default timestamp format for all queues.
|
private java.text.SimpleDateFormat m_formatter
public static final java.lang.String DEFAULT_FORMAT
private static final java.lang.String[] c_expression
private static java.util.regex.Pattern[] c_pattern
public Currently()
public Currently(java.lang.String formatString)
formatString
- complies to SimpleDateFormat
.public Currently(java.text.SimpleDateFormat format)
format
- is a description of the simple date format to use.public java.text.SimpleDateFormat getDateFormat()
setDateFormat( String )
,
setDateFormat( SimpleDateFormat )
public void setDateFormat(java.text.SimpleDateFormat format)
format
- is the new timestamp prefix format.setDateFormat( SimpleDateFormat )
,
getDateFormat()
public void setDateFormat(java.lang.String format)
format
- is the new timestamp prefix format as a string.setDateFormat( String )
,
getDateFormat()
public java.lang.String now()
now( Date )
public java.lang.String now(java.util.Date then)
then
- is a timestamp expressed as Date.now()
public static java.util.Date parse(java.lang.String stamp)
stamp
- is the textual timestamp representation.null
, if unparsable.public static java.lang.String iso8601(boolean zuluTime)
zuluTime
- returns a UTC formatted stamp, if true. Otherwise
the time will be formatted according to the local zone.iso8601( boolean, boolean, boolean, Date )
public static java.lang.String iso8601(boolean zuluTime, boolean extendedFormat, boolean withMillis, java.util.Date now)
zone | format | fraction | example |
---|---|---|---|
local | basic | integral | 20020523T140427-0500 |
UTC | basic | integral | 20020523190427Z |
local | extd. | integral | 2002-05-23T14:04:27-05:00 |
UTC | extd. | integral | 2002-05-23T19:04:27Z |
local | basic | millis | 20020523T140427.166-0500 |
UTC | basic | millis | 20020523190427.166Z |
local | extd. | millis | 2002-05-23T14:04:27.166-05:00 |
UTC | extd. | millis | 2002-05-23T19:04:27.166Z |
zuluTime
- returns a UTC formatted stamp, if true. Otherwise
the time will be formatted according to the local zone. Local time
should be prefixed with the 'T'.extendedFormat
- will use the extended ISO 8601 format which
separates the different timestamp items. If false, the basic
format will be used. In UTC and basic format, the 'T' separator
will be omitted.withMillis
- will put the millisecond extension into the timestamp.
If false, the time will be without millisecond fraction. The separator
is taken from DecimalFormatSymbols.getMinusSign()
,
which usually is a period or a comma.now
- is a time stamp as Date.