org.ceryle.util
Interface Clock

All Known Implementing Classes:
ClockImpl

public interface Clock

Provides some date-related constants and 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.

Since:
JDK1.3
Version:
$Id: Clock.java,v 3.10 2007-06-15 12:09:55 altheim Exp $
Author:
Murray Altheim

Field Summary
static int FIELD_CENTURY
          A constant indicating the centuries field or units.
static int FIELD_DAY
          A constant indicating the days (ie., day-of-month) field or units.
static int FIELD_DECADE
          A constant indicating the decades field or units.
static int FIELD_HOUR
          A constant indicating the hours field or units.
static int FIELD_MINUTE
          A constant indicating the minutes field or units.
static int FIELD_MONTH
          A constant indicating the months field or units.
static int FIELD_SECOND
          A constant indicating the seconds field or units.
static int FIELD_WEEK
          A constant indicating the weeks field or units.
static int FIELD_YEAR
          A constant indicating the years field or units.
 
Method Summary
 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 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.
 

Field Detail

FIELD_CENTURY

static final int FIELD_CENTURY
A constant indicating the centuries field or units.

See Also:
Constant Field Values

FIELD_DECADE

static final int FIELD_DECADE
A constant indicating the decades field or units.

See Also:
Constant Field Values

FIELD_YEAR

static final int FIELD_YEAR
A constant indicating the years field or units.

See Also:
Constant Field Values

FIELD_MONTH

static final int FIELD_MONTH
A constant indicating the months field or units.

See Also:
Constant Field Values

FIELD_WEEK

static final int FIELD_WEEK
A constant indicating the weeks field or units.

See Also:
Constant Field Values

FIELD_DAY

static final int FIELD_DAY
A constant indicating the days (ie., day-of-month) field or units.

See Also:
Constant Field Values

FIELD_HOUR

static final int FIELD_HOUR
A constant indicating the hours field or units.

See Also:
Constant Field Values

FIELD_MINUTE

static final int FIELD_MINUTE
A constant indicating the minutes field or units.

See Also:
Constant Field Values

FIELD_SECOND

static final int FIELD_SECOND
A constant indicating the seconds field or units.

See Also:
Constant Field Values
Method Detail

getTimeStamp

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. This can be called with new Date() or null to provide the current date and time.


getFriendlyTimeStamp

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. This can be called with new Date() or null to provide the current date and time.


getDateStamp

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).


parseTimeStamp

Date parseTimeStamp(String timeStamp)
                    throws ParseException
Returns a Date created by parsing the provided String in a timestamp of the form "yyyy-MM-dd'T'HH:mm:ss" in UTC. new Date() or null to provide the current date and time.

Throws:
ParseException

getTimeStampId

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. This uses characters that are "safe" as XML names, for use in IDs or filenames. This can be called with new Date() or null to provide the current date and time.


getCurrentDate

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.


getTimeStamp

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.


getTimeStampId

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. This uses characters that are "safe" as XML names, for use in IDs.


getDCDateStamp

String getDCDateStamp()
Returns a String representing the current date as a timestamp of the Dublin Core-compatible form "yyyy-MM-dd".


getCurrentDate

String getCurrentDate(int UTCOffset,
                      String dateformat)
Returns a String representing the current date and time. Parameters include an integer offset from UTC (eg., '0' for GMT, '-8' for Pacific Standard Time), and a format string conforming to java.text.SimpleDateFormat

See Also:
SimpleDateFormat, GregorianCalendar

getCurrentDate

String getCurrentDate(int UTCOffset,
                      String dateformat,
                      Date date)
Returns a String representing the provided Date. Parameters include an integer offset from UTC (eg., '0' for GMT, '-8' for Pacific Standard Time), and a format string conforming to java.text.SimpleDateFormat

See Also:
SimpleDateFormat, GregorianCalendar

getTimeString

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. This relies on the ResourceBundle-based localization in MessageId/Messages, but is not strictly internationalized: i.e., it always returns a String in HH-MM-SS order.



The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.