|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.northwestern.at.utils.DateTimeUtils
public class DateTimeUtils
Utilities for formatting dates and times.
Field Summary | |
---|---|
static int |
SECONDS_PER_DAY
Seconds per day. |
static int |
SECONDS_PER_HOUR
Seconds per hour. |
static int |
SECONDS_PER_MINUTE
Seconds per minute. |
Constructor Summary | |
---|---|
protected |
DateTimeUtils()
Don't allow instantiation, do allow overrides. |
Method Summary | |
---|---|
static java.util.Date |
addTimeToDate(java.util.Date date,
java.util.Date time)
Adds specified time of day to a date. |
static void |
clearTime(java.util.GregorianCalendar date)
Clears the time in a Gregorian calendar date. |
static java.lang.String |
formatDate(java.util.Date date)
Formats a date and time as (for example) "02/06/02 10:32 AM". |
static java.lang.String |
formatDateNoTime(java.util.Date date)
Formats a date as (for example) "2/6/2002". |
static java.lang.String |
formatDateOnAt(java.util.Date date)
Formats a date and time as (for example) "on 02/06/02 at 10:32 AM". |
static java.lang.String |
formatDuration(long milliseconds)
Format a time duration as "hh:mm:ss" |
static java.lang.String |
formatHTTPDate(java.util.Date date)
Formats a date and time in HTTP protocol format. |
static java.lang.String |
formatReadableTimer(long timerValue)
Formats a timer value in readable form. |
static java.lang.String |
formatTime(java.util.Date date)
Formats a time as (for example) "10:32 AM". |
static java.lang.String |
formatTimer(long timerValue,
boolean showZeroFields)
Formats a timer value as "days hh:mm:ss". |
static java.lang.String |
formatWordyDuration(long milliseconds)
Format a wordy time duration (e.g., "5 days, 3 hours, 23 minutes"). |
static long |
makeTimerValue(long days,
long hours,
long minutes,
long seconds)
Create a timer value from days, hours, minutes, seconds. |
static java.util.Date |
parseDate(java.lang.String str)
Parses a date. |
static java.util.Date |
parseTime(java.lang.String str)
Parses time of day in hh:mm aa format. |
static long |
parseTimer(java.lang.String timerString)
Parses a timer value specified as "days hh:mm:ss". |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int SECONDS_PER_DAY
public static final int SECONDS_PER_HOUR
public static final int SECONDS_PER_MINUTE
Constructor Detail |
---|
protected DateTimeUtils()
Method Detail |
---|
public static java.lang.String formatDate(java.util.Date date)
date
- The date and time.
public static java.lang.String formatDateNoTime(java.util.Date date)
date
- The date.
public static java.lang.String formatTime(java.util.Date date)
date
- The time.
public static java.util.Date parseDate(java.lang.String str)
str
- String.
public static java.util.Date parseTime(java.lang.String str)
str
- String.
First attempts to parse the time in "hh:mm aa" format. If that fails, tries "hh:mm". The latter allows for inputting the time on a 24 clock basis.
public static java.lang.String formatDateOnAt(java.util.Date date)
date
- The date and time.
public static java.lang.String formatDuration(long milliseconds)
milliseconds
- Time duration in milliseconds
public static java.lang.String formatWordyDuration(long milliseconds)
milliseconds
- Time duration in milliseconds
public static void clearTime(java.util.GregorianCalendar date)
date
- The date. public static java.util.Date addTimeToDate(java.util.Date date, java.util.Date time)
date
- The date.time
- The time.
public static java.lang.String formatHTTPDate(java.util.Date date)
date
- The date and time.
public static long makeTimerValue(long days, long hours, long minutes, long seconds)
days
- Days.hours
- Hours.minutes
- Minutes.seconds
- Seconds.
Note: The parameters are assumed to contain legal values.
public static java.lang.String formatTimer(long timerValue, boolean showZeroFields)
timerValue
- The timer value in milliseconds.showZeroFields
- True to show explicit zero for
days when days value is zero, and/or
explicit 00:00:00 when hh:mm:ss
value is zero.
public static java.lang.String formatReadableTimer(long timerValue)
timerValue
- The timer value in milliseconds.
The readable format is: n day(s), h hours, m minutes, s seconds.
public static long parseTimer(java.lang.String timerString)
timerString
- The timer string to be parsed.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |