org.barracudamvc.plankton
Class DateUtil

java.lang.Object
  extended by org.barracudamvc.plankton.DateUtil

public class DateUtil
extends Object

class holding some useful date utilities


Field Summary
static long MILLISECONDS_IN_DAY
           
static long SECONDS_IN_DAY
           
 
Constructor Summary
DateUtil()
           
 
Method Summary
static String getDateStr(Date date)
          Easily format a date (default = SHORT).
static String getDateStr(long millis)
          Easily format a millis value as a date (default = SHORT)
static Calendar getElapsed(long elapsed)
          get a Calendar representing an elapsed amt of time
static String getElapsedStr(long elapsed)
          get a String describing an elapsed amt of time
static Calendar getFirstDate(int theOffsetInDays)
           
static Calendar getFirstDateToday()
           
static Calendar getFirstDateTomorrow()
           
static Calendar getFirstDateYesterday()
           
static String getFullDateStr(Date date)
          Easily format a date (FULL).
static Calendar getLastDate(int theOffsetInDays)
           
static Calendar getLastDateToday()
           
static Calendar getLastDateTomorrow()
           
static Calendar getLastDateYesterday()
           
static String getLongDateStr(Date date)
          Easily format a date (LONG).
static String getMedDateStr(Date date)
          Easily format a date (MEDIUM).
static int getNumberOfDaysBetween(Date d1, Date d2)
          get the number of days between two dates (inclusive of the latter date - so the number of days between Monday of this week and Monday of next week will be 7).
static String getShortDateStr(Date date)
          Easily format a date (SHORT).
static String getShortTimeStr()
          Easily format the current time as a short time string (default)
static String getShortTimeStr(Date time)
          Easily format a date as a short time string (SHORT time)
static String getShortTimeStr(long millis)
          Easily format a millis value as a short time string (default)
static String getTimestampStr()
          Easily format the current time as a timestamp (default)
static String getTimestampStr(Date timestamp)
          Easily format a date as a timestamp (SHORT date, MEDIUM time)
static String getTimestampStr(long millis)
          Easily format a millis value as a timestamp (default)
static String getTimeStr()
          Easily format the current time as a time string (default)
static String getTimeStr(Date time)
          Easily format a date as a time string (MEDIUM time)
static String getTimeStr(long millis)
          Easily format a millis value as a time string (default)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SECONDS_IN_DAY

public static final long SECONDS_IN_DAY
See Also:
Constant Field Values

MILLISECONDS_IN_DAY

public static final long MILLISECONDS_IN_DAY
See Also:
Constant Field Values
Constructor Detail

DateUtil

public DateUtil()
Method Detail

getDateStr

public static String getDateStr(long millis)
Easily format a millis value as a date (default = SHORT)

Since:
csc_080904_1

getDateStr

public static String getDateStr(Date date)
Easily format a date (default = SHORT).

Since:
csc_080904_1

getShortDateStr

public static String getShortDateStr(Date date)
Easily format a date (SHORT). SHORT is completely numeric, such as 12.13.52 or 3:30pm

Since:
csc_080904_1

getMedDateStr

public static String getMedDateStr(Date date)
Easily format a date (MEDIUM). MEDIUM is longer, such as Jan 12, 1952

Since:
csc_080904_1

getLongDateStr

public static String getLongDateStr(Date date)
Easily format a date (LONG). LONG is longer, such as January 12, 1952 or 3:30:32pm

Since:
csc_080904_1

getFullDateStr

public static String getFullDateStr(Date date)
Easily format a date (FULL). FULL is pretty completely specified, such as Tuesday, April 12, 1952 AD or 3:30:42pm PST.

Since:
csc_080904_1

getTimestampStr

public static String getTimestampStr()
Easily format the current time as a timestamp (default)

Since:
csc_080904_1

getTimestampStr

public static String getTimestampStr(long millis)
Easily format a millis value as a timestamp (default)

Since:
csc_080904_1

getTimestampStr

public static String getTimestampStr(Date timestamp)
Easily format a date as a timestamp (SHORT date, MEDIUM time)

Since:
csc_080904_1

getTimeStr

public static String getTimeStr()
Easily format the current time as a time string (default)

Since:
csc_080904_1

getTimeStr

public static String getTimeStr(long millis)
Easily format a millis value as a time string (default)

Since:
csc_080904_1

getTimeStr

public static String getTimeStr(Date time)
Easily format a date as a time string (MEDIUM time)

Since:
csc_080904_1

getShortTimeStr

public static String getShortTimeStr()
Easily format the current time as a short time string (default)

Since:
csc_102904_1

getShortTimeStr

public static String getShortTimeStr(long millis)
Easily format a millis value as a short time string (default)

Since:
csc_102904_1

getShortTimeStr

public static String getShortTimeStr(Date time)
Easily format a date as a short time string (SHORT time)


getElapsed

public static Calendar getElapsed(long elapsed)
get a Calendar representing an elapsed amt of time

Since:
csc_080904_1

getElapsedStr

public static String getElapsedStr(long elapsed)
get a String describing an elapsed amt of time

Since:
csc_080904_1

getNumberOfDaysBetween

public static int getNumberOfDaysBetween(Date d1,
                                         Date d2)
get the number of days between two dates (inclusive of the latter date - so the number of days between Monday of this week and Monday of next week will be 7). If either date is null, it will be defaulted to today. If d1d2 the result will be a negative number representing the # of days between the two. NOTE: there's probably a simpler way of doing this, but its not just as straightforward as (int) (((d1.getTime()-d2.getTime())/86400000)+1)...the problem is, you want to know _how many dates_ actually fall within this range. If someone has a better suggestion than looping, feel free to speak up

Since:
csc_122804_1

getFirstDateToday

public static Calendar getFirstDateToday()

getLastDateToday

public static Calendar getLastDateToday()

getFirstDateTomorrow

public static Calendar getFirstDateTomorrow()

getLastDateTomorrow

public static Calendar getLastDateTomorrow()

getFirstDateYesterday

public static Calendar getFirstDateYesterday()

getLastDateYesterday

public static Calendar getLastDateYesterday()

getFirstDate

public static Calendar getFirstDate(int theOffsetInDays)

getLastDate

public static Calendar getLastDate(int theOffsetInDays)


Copyright © 2006 BarracudaMVC.org All Rights Reserved.