public class Currently extends Object
Date
,
SimpleDateFormat
Modifier and Type | Field and Description |
---|---|
private static String[] |
c_expression
Store the regular expressions necessary to parse ISO timestamps.
|
private static Pattern[] |
c_pattern
Stores compiled patterns at first use, quasi-Singleton.
|
static String |
DEFAULT_FORMAT
Default time format, which is compact and has a timezone
|
private 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(SimpleDateFormat format)
Ctor: Create a new instance with a formatting string for time stamps.
|
Currently(String formatString)
Ctor: Create a new instance with a formatting string for time stamps.
|
Modifier and Type | Method and Description |
---|---|
SimpleDateFormat |
getDateFormat()
Accessor: Obtains the default timestamp format for all queues.
|
static 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 String |
iso8601(boolean zuluTime,
boolean extendedFormat,
boolean withMillis,
Date now)
Ignores any internal date format, and tries to show a complete
date/timp stamp in extended ISO 8601 format.
|
String |
now()
Obtains the current time as formatted string according to
the format option.
|
String |
now(Date then)
Obtains the current time as formatted string according to
the format option.
|
static Date |
parse(String stamp)
Parses one of the ISO 8601 that it produces.
|
void |
setDateFormat(SimpleDateFormat format)
Accessor: Sets the default timestamp format for all queues.
|
void |
setDateFormat(String format)
Accessor: Sets the default timestamp format for all queues.
|
private SimpleDateFormat m_formatter
public static final String DEFAULT_FORMAT
private static final String[] c_expression
private static Pattern[] c_pattern
public Currently()
public Currently(String formatString)
formatString
- complies to SimpleDateFormat
.public Currently(SimpleDateFormat format)
format
- is a description of the simple date format to use.public SimpleDateFormat getDateFormat()
setDateFormat( String )
,
setDateFormat( SimpleDateFormat )
public void setDateFormat(SimpleDateFormat format)
format
- is the new timestamp prefix format.setDateFormat( SimpleDateFormat )
,
getDateFormat()
public void setDateFormat(String format)
format
- is the new timestamp prefix format as a string.setDateFormat( String )
,
getDateFormat()
public String now()
now( Date )
public String now(Date then)
then
- is a timestamp expressed as Date.now()
public static Date parse(String stamp)
stamp
- is the textual timestamp representation.null
, if unparsable.public static 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 String iso8601(boolean zuluTime, boolean extendedFormat, boolean withMillis, 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.Copyright © 2011 The University of Southern California. All Rights Reserved.