|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.ceryle.util.ClockImpl
public class ClockImpl
Implements Clock, providing some general utility
methods relating to dates and times, such as a date/time stamp as a String.
Since it's rather expensive to generate a timestamp statically, if a lot
of timestamps are needed, generating them from a Clock object is recommended.
| Field Summary | |
|---|---|
static String |
CDT_FORMAT
Current date and time format "EEE, MMM d, yyyy 'at' hh:mm:ss a zzz", eg., "Mon, Sep 14 2002 at 14:23:55". |
static String |
DATE_FORMAT
Simple datestamp format "yyyyMMdd", eg., "20020914". |
static String |
DC_FORMAT
DC-compatible timestamp format "yyyy-MM-dd", eg., "2002-09-14". |
static String |
FTS_FORMAT
Friendly timestamp format "yyyy-MM-dd HH:mm:ss", eg., "2002-09-14 14:23:55". |
static long[] |
SEC_PER_FIELD
Constants for calculating elapsed times. |
static String |
TS_FORMAT
Timestamp format "yyyy-MM-dd'T'HH:mm:ss", eg., "2002-09-14T14:23:55". |
static String |
TSID_FORMAT
Timestamp ID format "yyyy-MM-dd'T'HH_mm_ss", eg., "2002-09-14T14_23_55". |
| Fields inherited from interface org.ceryle.util.Clock |
|---|
FIELD_CENTURY, FIELD_DAY, FIELD_DECADE, FIELD_HOUR, FIELD_MINUTE, FIELD_MONTH, FIELD_SECOND, FIELD_WEEK, FIELD_YEAR |
| Constructor Summary | |
|---|---|
ClockImpl()
Default constructor for a ClockImpl object using the UTC timezone. |
|
ClockImpl(int offset)
Constructor for a ClockImpl object with the provided offset from UTC, where offset is the number of milliseconds to add to UTC to obtain local time. |
|
| Method Summary | |
|---|---|
static int |
convertToGregorianField(int field)
Convert the provided field index to the GregorianCalendar equivalent. |
String |
getCurrentDate(int UTCOffset)
Returns a String representing the current date and time, provided an integer offset from UTC (eg., '-8' for Pacific Standard Time), using a default format. |
String |
getCurrentDate(int UTCOffset,
String dateformat)
Returns a String representing the current date and time. |
String |
getCurrentDate(int UTCOffset,
String dateformat,
Date date)
Returns a String representing the provided Date. |
String |
getDateStamp(Date date)
Returns a String representing either the date parameter or if null, the current date as a timestamp of the form "yyyyMMdd" (for use in filenames). |
String |
getDCDateStamp()
Returns a String representing the current date as a timestamp of the Dublin Core-compatible form "yyyy-MM-dd". |
String |
getDCDateStamp(Date date)
Returns a String representing the provided date and time as a timestamp of the form "yyyy-MM-dd" in UTC. |
static int[] |
getDurationFromDates(Date startDate,
Date endDate,
boolean cumulative)
Return the elapsed time as an int[] array between the start and end extents of the two Dates. |
String |
getFriendlyTimeStamp(Date date)
Returns a String representing the provided date and time as a timestamp of the form "yyyy-MM-dd HH:mm:ss" in UTC. |
String |
getTimeStamp()
Returns a String representing the current date and time as a timestamp of the form "yyyy-MM-dd'T'HH:mm:ss" in UTC. |
String |
getTimeStamp(Date date)
Returns a String representing the provided date and time as a timestamp of the form "yyyy-MM-dd'T'HH:mm:ss" in UTC. |
String |
getTimeStampId()
Returns a String representing the current date and time as a timestamp of the form "yyyy-MM-dd'T'HH_mm_ss" in UTC. |
String |
getTimeStampId(Date date)
Returns a String representing the provided date and time as a timestamp of the form "yyyy-MM-dd'T'HH_mm_ss" in UTC. |
String |
getTimeString(long millis)
Returns a properly-formatted, localized String describing the number of hours, minutes and seconds represented by a long value in milliseconds. |
Date |
parseTimeStamp(String timeStamp)
Returns a Date created by parsing the provided String in a timestamp of the form "yyyy-MM-dd'T'HH:mm:ss" in UTC. |
int |
parseYear(String dateString)
Returns a year value created by parsing the provided String. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String DC_FORMAT
public static final String TS_FORMAT
public static final String DATE_FORMAT
public static final String FTS_FORMAT
public static final String TSID_FORMAT
public static final String CDT_FORMAT
public static final long[] SEC_PER_FIELD
| Constructor Detail |
|---|
public ClockImpl()
public ClockImpl(int offset)
| Method Detail |
|---|
public String getDCDateStamp(Date date)
public String getTimeStamp(Date date)
getTimeStamp in interface Clockpublic String getFriendlyTimeStamp(Date date)
getFriendlyTimeStamp in interface Clockpublic String getDateStamp(Date date)
getDateStamp in interface Clock
public Date parseTimeStamp(String timeStamp)
throws ParseException
parseTimeStamp in interface ClockParseExceptionpublic String getTimeStampId(Date date)
getTimeStampId in interface Clockpublic int parseYear(String dateString)
public String getCurrentDate(int UTCOffset)
getCurrentDate in interface Clockpublic String getTimeStamp()
getTimeStamp in interface Clockpublic String getTimeStampId()
getTimeStampId in interface Clockpublic String getDCDateStamp()
getDCDateStamp in interface Clock
public String getCurrentDate(int UTCOffset,
String dateformat)
getCurrentDate in interface ClockSimpleDateFormat,
GregorianCalendar
public String getCurrentDate(int UTCOffset,
String dateformat,
Date date)
getCurrentDate in interface ClockSimpleDateFormat,
GregorianCalendarpublic String getTimeString(long millis)
getTimeString in interface Clock
public static int[] getDurationFromDates(Date startDate,
Date endDate,
boolean cumulative)
TimeLine.
startDate - the start date of the duration.endDate - the end date of the duration.cumulative - when true, the duration is expressed by all the returned fields;
when false, each field represents the duration.
TimeLinepublic static int convertToGregorianField(int field)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||