se.datadosen.util
Class Dates

java.lang.Object
  extended by se.datadosen.util.Dates

public class Dates
extends java.lang.Object

Utility class to simplify date display and date arithmetic


Method Summary
static int dateDiff(char unit, java.util.Date testDate, java.util.Date refDate)
          Return difference between two dates in the unit specified by unit
static int dateDiff(char unit, java.util.Date testDate, java.lang.String refDate)
          Return difference between two dates in the unit specified by unit
static int dateDiff(char unit, java.lang.String testDate, java.util.Date refDate)
          Return difference between two dates in the unit specified by unit
static int dateDiff(char unit, java.lang.String testDate, java.lang.String refDate)
          Return difference between two dates in the unit specified by unit
static java.lang.String format(java.util.Date date)
          Return a date formatted according to the default date pattern
static java.lang.String format(java.util.Date date, java.lang.String pattern)
          Return a date formatted according to the given date pattern
static java.lang.String format(java.lang.String dateString)
          Return a date formatted according to the default date pattern
static java.lang.String format(java.lang.String dateString, java.lang.String pattern)
          Return a date formatted according to the given date pattern
static java.util.Date now()
          Get Date object representing now
static java.util.Date toDate(long dateMillis)
          Return a date object from milliseconds since epoch
static java.util.Date toDate(java.lang.String dateString)
          Return a date object from a string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

now

public static java.util.Date now()
Get Date object representing now

Returns:

format

public static java.lang.String format(java.util.Date date)
Return a date formatted according to the default date pattern

Parameters:
date -
Returns:

format

public static java.lang.String format(java.lang.String dateString)
Return a date formatted according to the default date pattern

Parameters:
dateString -
Returns:

format

public static java.lang.String format(java.util.Date date,
                                      java.lang.String pattern)
Return a date formatted according to the given date pattern

Parameters:
date -
pattern -
Returns:

format

public static java.lang.String format(java.lang.String dateString,
                                      java.lang.String pattern)
Return a date formatted according to the given date pattern

Parameters:
dateString -
pattern -
Returns:

toDate

public static java.util.Date toDate(java.lang.String dateString)
Return a date object from a string

Parameters:
dateString -
Returns:

toDate

public static java.util.Date toDate(long dateMillis)
Return a date object from milliseconds since epoch

Parameters:
dateMillis -
Returns:

dateDiff

public static int dateDiff(char unit,
                           java.util.Date testDate,
                           java.util.Date refDate)
                    throws java.lang.IllegalArgumentException
Return difference between two dates in the unit specified by unit

Parameters:
unit - 'D' for day difference
testDate -
refDate -
Returns:
Throws:
java.lang.IllegalArgumentException

dateDiff

public static int dateDiff(char unit,
                           java.lang.String testDate,
                           java.util.Date refDate)
                    throws java.lang.IllegalArgumentException
Return difference between two dates in the unit specified by unit

Parameters:
unit - 'D' for day difference
testDate -
refDate -
Returns:
Throws:
java.lang.IllegalArgumentException

dateDiff

public static int dateDiff(char unit,
                           java.util.Date testDate,
                           java.lang.String refDate)
                    throws java.lang.IllegalArgumentException
Return difference between two dates in the unit specified by unit

Parameters:
unit - 'D' for day difference
testDate -
refDate -
Returns:
Throws:
java.lang.IllegalArgumentException

dateDiff

public static int dateDiff(char unit,
                           java.lang.String testDate,
                           java.lang.String refDate)
                    throws java.lang.IllegalArgumentException
Return difference between two dates in the unit specified by unit

Parameters:
unit - 'D' for day difference
testDate -
refDate -
Returns:
Throws:
java.lang.IllegalArgumentException