org.simoes.util
Class DateUtil

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

public class DateUtil
extends java.lang.Object

Utility class for manipulating Dates in Java that I have found useful.

Author:
Chris Simoes

Constructor Summary
DateUtil()
           
 
Method Summary
static boolean checkDate(int day, int month, int year)
          Returns a true or false based on the whether or not the date is valid.
static java.util.Calendar createCalendar(java.util.Date date)
           
static java.lang.String createDateOnlyFilename(java.util.Date d)
          Creates a String that represents the Date passed in.
static java.lang.String createDateOnlyString(java.util.Date d)
          Creates a String that represents the Date passed in, using the format passed in.
static java.lang.String createDateString()
          Creates a String that represents the current Date and Time.
static java.lang.String createDateString(java.util.Date d)
          Creates a String that represents the Date passed in.
static java.lang.String createDateString(java.lang.String d)
          Creates a String formatted properly based on the Date passed in.
static java.sql.Date utilDate2SQLDate(java.util.Date d)
           
static java.sql.Timestamp utilDate2Timestamp(java.util.Date d)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateUtil

public DateUtil()
Method Detail

utilDate2SQLDate

public static java.sql.Date utilDate2SQLDate(java.util.Date d)

utilDate2Timestamp

public static java.sql.Timestamp utilDate2Timestamp(java.util.Date d)

createDateString

public static java.lang.String createDateString()
Creates a String that represents the current Date and Time.


createDateString

public static java.lang.String createDateString(java.util.Date d)
Creates a String that represents the Date passed in. If the date passed in is null the null is returned.


createDateString

public static java.lang.String createDateString(java.lang.String d)
Creates a String formatted properly based on the Date passed in. Is expecting a string of the following form: "year-month-day hour:minute:second" This is the date format returned from MSSQL server via JDBC Note: hour is from 0-23 If the date passed in is null the null is returned.


createDateOnlyString

public static java.lang.String createDateOnlyString(java.util.Date d)
Creates a String that represents the Date passed in, using the format passed in. For formatting options check out the SimpleDateFormat object. If the date passed in is null the null is returned.


createDateOnlyFilename

public static java.lang.String createDateOnlyFilename(java.util.Date d)
Creates a String that represents the Date passed in. Formats the Date so that it can be used as a filename. For formatting options check out the SimpleDateFormat object. If the date passed in is null the null is returned.


createCalendar

public static java.util.Calendar createCalendar(java.util.Date date)

checkDate

public static boolean checkDate(int day,
                                int month,
                                int year)
Returns a true or false based on the whether or not the date is valid.