|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.lang.time.DateUtils
com.foxsmart.ic.util.DateUtils
public class DateUtils
This class provides various date and time utilities via static methods.
| Field Summary | |
|---|---|
static java.lang.String |
DATE_FORMAT_DD_MMM_YYYY
The date format of "dd MMM yyyy" |
static java.lang.String |
DATE_FORMAT_MMM_D_YYYY
The date format of "MMMM d, yyyy" |
static java.lang.String |
DEFAULT_DATE_FORMAT
The default date format of "MMMM d, yyyy" |
static java.lang.String |
DEFAULT_TIME_FORMAT
The default time format of "MMM d, yyyy h:mm:ss a" |
static java.lang.String |
TIME_FORMAT_MMM_D_YYYY_H_MM_A
The time format of "MMM d, yyyy h:mm a" |
| Fields inherited from class org.apache.commons.lang.time.DateUtils |
|---|
MILLIS_IN_DAY, MILLIS_IN_HOUR, MILLIS_IN_MINUTE, MILLIS_IN_SECOND, MILLIS_PER_DAY, MILLIS_PER_HOUR, MILLIS_PER_MINUTE, MILLIS_PER_SECOND, RANGE_MONTH_MONDAY, RANGE_MONTH_SUNDAY, RANGE_WEEK_CENTER, RANGE_WEEK_MONDAY, RANGE_WEEK_RELATIVE, RANGE_WEEK_SUNDAY, SEMI_MONTH, UTC_TIME_ZONE |
| Constructor Summary | |
|---|---|
DateUtils()
|
|
| Method Summary | |
|---|---|
static java.lang.String |
formatCalendar(java.util.Calendar calendar)
Formats the passed in calendar into a dd-MMM-yyyy HH:mm:ss format. |
static java.lang.String |
formatCalendar(java.util.Calendar calendar,
java.lang.String format)
Formats the passed in calendar into the format specified. |
static java.lang.String |
formatDate(java.util.Date date)
Formats the passed in date with the default format and returns it as a String. |
static java.lang.String |
formatDate(java.util.Date date,
java.lang.String format)
Formats the passed in date and returns it as a String. |
static java.lang.String |
formatElapsedTime(long elapsedTime,
boolean displayMilliseconds)
Formats an elapsed period of time in milliseconds. |
static java.lang.String |
formatTime(java.util.Calendar calendar)
Formats the passed in date/time and returns it as a String. |
static java.lang.String |
formatTime(java.util.Date date)
Formats the passed in date/time with the default format and returns it as a String. |
static java.lang.String |
formatTime(java.util.Date date,
java.lang.String format)
Formats the passed in date/time and returns it as a String. |
static java.util.Calendar |
getCalendarUsingFormat(java.lang.String dateString,
java.lang.String dateFormat)
Gets a Calendar from the passed in date as a String. |
static java.util.Calendar |
getCalendarUsingFormats(java.lang.String dateString,
java.lang.String[] dateFormats)
Gets a Calendar from the passed in date as a String. |
static java.util.Calendar |
getCurrentDayAtMidnight()
Gets the current date at midnight. |
static long |
getElapsedDays(java.util.Calendar startTime,
java.util.Calendar endTime)
Gets the elapsed number of days between the start and end times. |
static long |
getElapsedDays(long elapsedTime)
Gets the elapsed number of days given the elapsed miliseconds. |
static long |
getElapsedTime(java.lang.String key)
Get elapsed time from a previously started timer. |
static java.lang.String |
getMonth(int month)
Gets the string month based on the passed in integer month. |
static int |
getMonth(java.lang.String month)
Get the integer month based on the spelled out month. |
static java.lang.String |
startTimer()
Starts a timer and returns a key to this timer. |
static long |
stopTimer(java.lang.String key)
Stops a previously started timer. |
| Methods inherited from class org.apache.commons.lang.time.DateUtils |
|---|
add, addDays, addHours, addMilliseconds, addMinutes, addMonths, addSeconds, addWeeks, addYears, isSameDay, isSameDay, isSameInstant, isSameInstant, isSameLocalTime, iterator, iterator, iterator, parseDate, round, round, round, truncate, truncate, truncate |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String DEFAULT_DATE_FORMAT
public static final java.lang.String DATE_FORMAT_MMM_D_YYYY
public static final java.lang.String DATE_FORMAT_DD_MMM_YYYY
public static final java.lang.String DEFAULT_TIME_FORMAT
public static final java.lang.String TIME_FORMAT_MMM_D_YYYY_H_MM_A
| Constructor Detail |
|---|
public DateUtils()
| Method Detail |
|---|
public static java.lang.String formatDate(java.util.Date date)
date - The date to format as a 'Date'
public static java.lang.String formatDate(java.util.Date date,
java.lang.String format)
date - The date to format as a 'Date'format - The date format to use.
public static java.lang.String formatTime(java.util.Date date)
date - The date to format as a 'Time'
public static java.lang.String formatTime(java.util.Date date,
java.lang.String format)
date - The date to format as a 'Time'format - The time format to use.
public static java.lang.String formatTime(java.util.Calendar calendar)
calendar - The date to format as a 'Calendar'
public static java.lang.String formatElapsedTime(long elapsedTime,
boolean displayMilliseconds)
elapsedTime - The elapsed time in millilseconds to formatdisplayMilliseconds - Whether to display milliseconds or not
public static java.lang.String startTimer()
public static long getElapsedTime(java.lang.String key)
key - The key for the started timer.
public static long getElapsedDays(java.util.Calendar startTime,
java.util.Calendar endTime)
startTime - the start time.endTime - the end time.
public static long getElapsedDays(long elapsedTime)
elapsedTime - the elapsed number of miliseconds.
public static long stopTimer(java.lang.String key)
key - The key for the started timer.
public static int getMonth(java.lang.String month)
throws java.text.ParseException
month - The month to get the integer from.
java.text.ParseException - if the month wasn't recognizedpublic static java.util.Calendar getCurrentDayAtMidnight()
public static java.lang.String getMonth(int month)
throws java.lang.IllegalArgumentException
month - The month
java.lang.IllegalArgumentException - if the month is out of rangepublic static java.lang.String formatCalendar(java.util.Calendar calendar)
calendar - The calendar to format
public static java.lang.String formatCalendar(java.util.Calendar calendar,
java.lang.String format)
calendar - The calendar to formatformat - The format.
public static java.util.Calendar getCalendarUsingFormat(java.lang.String dateString,
java.lang.String dateFormat)
dateString - The date in the format of a String.dateFormat - The format of the date pattern. If no pattern was specified, the default MM/dd/yyyy HH:mm:ss
will be used.
java.lang.IllegalArgumentException - if the date or format is invalid.
public static java.util.Calendar getCalendarUsingFormats(java.lang.String dateString,
java.lang.String[] dateFormats)
dateString - The date in the format of a String.dateFormats - The array of date formats. If this parameter is null, the following two formats will be
used: "MM/dd/yyyy" and "MM/dd/yyyy HH:mm:ss".
java.lang.IllegalArgumentException - if the date or format is invalid.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||