Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.roller.util
Class DateUtil  view DateUtil download DateUtil.java

java.lang.Object
  extended byorg.roller.util.DateUtil

public class DateUtil
extends java.lang.Object

General purpose date utilities.


Field Summary
static java.text.SimpleDateFormat[] mDateFormats
           
private static java.text.SimpleDateFormat mFormat8chars
           
private static java.text.SimpleDateFormat mFormatIso8601
           
private static java.text.SimpleDateFormat mFormatRfc822
           
static long millisInDay
           
 
Constructor Summary
DateUtil()
           
 
Method Summary
static java.lang.String defaultDate(java.util.Date date)
           
static java.text.SimpleDateFormat defaultDateFormat()
           
static java.lang.String defaultTimestamp(java.util.Date date)
           
static java.text.SimpleDateFormat defaultTimestampFormat()
           
static java.lang.String format(java.util.Date aDate, java.text.SimpleDateFormat aFormat)
          Returns a string the represents the passed-in date parsed according to the passed-in format.
static java.lang.String format8chars(java.util.Date date)
           
static java.lang.String formatDateString(java.lang.String aString, java.text.SimpleDateFormat aFormat)
          Tries to take the passed-in String and format it as a date string in the the passed-in format.
static java.lang.String formatIso8601(java.util.Date date)
           
static java.lang.String formatRfc822(java.util.Date date)
           
static java.lang.String friendlyDate(java.util.Date date)
           
static java.lang.String friendlyDate(java.util.Date date, boolean minimalFormat)
          Format the date using the "friendly" date format.
static java.text.SimpleDateFormat friendlyDateFormat(boolean minimalFormat)
          Returns a "friendly" date format.
static java.lang.String friendlyTimestamp(java.util.Date date)
           
static java.text.SimpleDateFormat friendlyTimestampFormat()
           
static java.lang.String fullDate(java.util.Date date)
           
static java.text.SimpleDateFormat fullDateFormat()
           
static java.util.Date getEndOfDay(java.util.Date day)
          Returns a Date set to the last possible millisecond of the day, just before midnight.
static java.util.Date getEndOfDay(java.util.Date day, java.util.Calendar cal)
           
static java.text.SimpleDateFormat[] getFormats()
          Gets the array of SimpleDateFormats that DateUtil knows about.
static java.util.Date getStartOfDay(java.util.Date day)
          Returns a Date set to the first possible millisecond of the day, just after midnight.
static java.util.Date getStartOfDay(java.util.Date day, java.util.Calendar cal)
          Returns a Date set to the first possible millisecond of the day, just after midnight.
static boolean isValidDateRange(java.util.Date startDate, java.util.Date endDate)
          Returns true if endDate is after startDate or if startDate equals endDate or if they are the same date.
static boolean isValidDateRange(java.util.Date startDate, java.util.Date endDate, boolean equalOK)
          Returns true if endDate is after startDate or if startDate equals endDate.
static java.lang.String minimalDate(java.util.Date date)
           
static java.text.SimpleDateFormat minimalDateFormat()
           
static java.sql.Timestamp now()
          Returns a java.sql.Timestamp equal to the current time
static java.util.Date parse(java.lang.String aValue, java.text.SimpleDateFormat aFormat)
          Returns a Date using the passed-in string and format.
static java.util.Date parseFromFormats(java.lang.String aValue)
           
static java.sql.Timestamp parseTimestampFromFormats(java.lang.String aValue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

millisInDay

public static final long millisInDay
See Also:
Constant Field Values

mDateFormats

public static java.text.SimpleDateFormat[] mDateFormats

mFormat8chars

private static final java.text.SimpleDateFormat mFormat8chars

mFormatIso8601

private static final java.text.SimpleDateFormat mFormatIso8601

mFormatRfc822

private static final java.text.SimpleDateFormat mFormatRfc822
Constructor Detail

DateUtil

public DateUtil()
Method Detail

getFormats

public static java.text.SimpleDateFormat[] getFormats()
Gets the array of SimpleDateFormats that DateUtil knows about.


getEndOfDay

public static java.util.Date getEndOfDay(java.util.Date day)
Returns a Date set to the last possible millisecond of the day, just before midnight. If a null day is passed in, a new Date is created. midnight (00m 00h 00s)


getEndOfDay

public static java.util.Date getEndOfDay(java.util.Date day,
                                         java.util.Calendar cal)

getStartOfDay

public static java.util.Date getStartOfDay(java.util.Date day)
Returns a Date set to the first possible millisecond of the day, just after midnight. If a null day is passed in, a new Date is created. midnight (00m 00h 00s)


getStartOfDay

public static java.util.Date getStartOfDay(java.util.Date day,
                                           java.util.Calendar cal)
Returns a Date set to the first possible millisecond of the day, just after midnight. If a null day is passed in, a new Date is created. midnight (00m 00h 00s)


parseFromFormats

public static java.util.Date parseFromFormats(java.lang.String aValue)

parseTimestampFromFormats

public static java.sql.Timestamp parseTimestampFromFormats(java.lang.String aValue)

now

public static java.sql.Timestamp now()
Returns a java.sql.Timestamp equal to the current time


format

public static java.lang.String format(java.util.Date aDate,
                                      java.text.SimpleDateFormat aFormat)
Returns a string the represents the passed-in date parsed according to the passed-in format. Returns an empty string if the date or the format is null.


formatDateString

public static java.lang.String formatDateString(java.lang.String aString,
                                                java.text.SimpleDateFormat aFormat)
Tries to take the passed-in String and format it as a date string in the the passed-in format.


parse

public static java.util.Date parse(java.lang.String aValue,
                                   java.text.SimpleDateFormat aFormat)
                            throws java.text.ParseException
Returns a Date using the passed-in string and format. Returns null if the string is null or empty or if the format is null. The string must match the format.


isValidDateRange

public static boolean isValidDateRange(java.util.Date startDate,
                                       java.util.Date endDate)
Returns true if endDate is after startDate or if startDate equals endDate or if they are the same date. Returns false if either value is null.


isValidDateRange

public static boolean isValidDateRange(java.util.Date startDate,
                                       java.util.Date endDate,
                                       boolean equalOK)
Returns true if endDate is after startDate or if startDate equals endDate. Returns false if either value is null. If equalOK, returns true if the dates are equal.


defaultTimestampFormat

public static java.text.SimpleDateFormat defaultTimestampFormat()

defaultDateFormat

public static java.text.SimpleDateFormat defaultDateFormat()

defaultTimestamp

public static java.lang.String defaultTimestamp(java.util.Date date)

defaultDate

public static java.lang.String defaultDate(java.util.Date date)

friendlyTimestampFormat

public static java.text.SimpleDateFormat friendlyTimestampFormat()

friendlyTimestamp

public static java.lang.String friendlyTimestamp(java.util.Date date)

format8chars

public static java.lang.String format8chars(java.util.Date date)

formatRfc822

public static java.lang.String formatRfc822(java.util.Date date)

formatIso8601

public static java.lang.String formatIso8601(java.util.Date date)

minimalDateFormat

public static java.text.SimpleDateFormat minimalDateFormat()

minimalDate

public static java.lang.String minimalDate(java.util.Date date)

fullDateFormat

public static java.text.SimpleDateFormat fullDateFormat()

fullDate

public static java.lang.String fullDate(java.util.Date date)

friendlyDateFormat

public static java.text.SimpleDateFormat friendlyDateFormat(boolean minimalFormat)
Returns a "friendly" date format.


friendlyDate

public static java.lang.String friendlyDate(java.util.Date date,
                                            boolean minimalFormat)
Format the date using the "friendly" date format.


friendlyDate

public static java.lang.String friendlyDate(java.util.Date date)