|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.devexperts.util.TimeFormat
public class TimeFormat
Utility class for parsing and formatting dates and times in ISO-compatible format.
Field Summary | |
---|---|
static TimeFormat |
DEFAULT
An instance of TimeFormat that corresponds to default timezone as returned by TimeZone.getDefault() method. |
static TimeFormat |
GMT
An instance of TimeFormat that corresponds to GMT timezone as returned by TimeZone.getTimeZone("GMT") . |
Method Summary | |
---|---|
String |
format(Date time)
Converts Date object into string according to the format like yyyyMMdd-HHmmss. |
String |
format(long time)
This is a shortcut for format (new Date (time)). |
static TimeFormat |
getInstance(TimeZone timezone)
Returns TimeFormat instance for a specified timezone. |
TimeZone |
getTimeZone()
Returns timezone of this TimeFormat instance. |
Date |
parse(String value)
Reads Date from String. |
TimeFormat |
withMillis()
Returns TimeFormat instance that also includes milliseconds into string when using format method. |
TimeFormat |
withTimeZone()
Returns TimeFormat instance that also includes timezone into string when using format method. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final TimeFormat DEFAULT
TimeZone.getDefault()
method.
public static final TimeFormat GMT
TimeZone.getTimeZone("GMT")
.
Method Detail |
---|
public static TimeFormat getInstance(TimeZone timezone)
timezone
- timezone for TimeFormat.
NullPointerException
- if timezone is null.public TimeFormat withTimeZone()
format
method.
public TimeFormat withMillis()
format
method.
public Date parse(String value) throws InvalidFormatException, NullPointerException
It accepts the following formats of date:
TimePeriod.valueOf(String)
.
SimpleDateFormat
.
value
- String value to parse.
InvalidFormatException
- if value has wrong format.
NullPointerException
- if value == null.SimpleDateFormat
public String format(Date time) throws NullPointerException
Date
object into string according to the format like yyyyMMdd-HHmmss.
When withTimeZone()
was used to acquire this TimeFormat
instance,
then time zone is also included and formatted according to RFC 822 format (for example "+0300").
When withMillis()
was used to acquire this TimeFormat
instance,
the milliseconds are also included as .sss.
When time.getTime() == 0
this method returns string "0".
time
- date and time to format.
NullPointerException
- if time is null.public String format(long time)
format
(new Date
(time)).
public TimeZone getTimeZone()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |