javatools.util
Class DateUtil

java.lang.Object
  |
  +--javatools.util.DateUtil

public class DateUtil
extends java.lang.Object

A utility class for use with dates.


Constructor Summary
DateUtil()
           
 
Method Summary
static int daysInMonth(int month, int year)
          Returns the number of days in a month depending on the year.
static boolean leapYear(int year)
          Checks if a year is a leap year.
static int maxMonthSize(int month)
          Returns the maximum value of days in a month.
static java.sql.Date minusInfinity()
          Return a date represting a long time in the past.
static int monthSize(int month)
          Returns the month size.
static java.sql.Date plusInfinity()
          Return a date representing a long time in the future.
static java.sql.Timestamp timestampNow()
          Return a Timestamp object representing the time now.
static boolean validDate(int date, int month, int year)
          Checks if a date is vald.
 
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

minusInfinity

public static java.sql.Date minusInfinity()
Return a date represting a long time in the past.

Returns:
-infinity date.

plusInfinity

public static java.sql.Date plusInfinity()
Return a date representing a long time in the future. Sometimes people who don't like to use NULL values in databases use this as a kind of NULL value. Alternatively it can be sometimes useful in a SELECT to force use of an index.

Returns:
+infinity date.

timestampNow

public static java.sql.Timestamp timestampNow()
Return a Timestamp object representing the time now.

Returns:
Excuse me what time is it?

leapYear

public static boolean leapYear(int year)
Checks if a year is a leap year.

Parameters:
year - The year to check.
Returns:
true: the year is a leap year; false: the year is a normal year.

monthSize

public static int monthSize(int month)
Returns the month size.

Parameters:
month - The month to check.
Returns:
The number of contained days.

maxMonthSize

public static int maxMonthSize(int month)
Returns the maximum value of days in a month.

Parameters:
month - The month to check.
Returns:
The maximum number of days contained in this month.

daysInMonth

public static int daysInMonth(int month,
                              int year)
Returns the number of days in a month depending on the year. Month is zero based.

Parameters:
month - The month to check.
year - The year to use.
Returns:
The number of days in the month at a certain year.

validDate

public static boolean validDate(int date,
                                int month,
                                int year)
Checks if a date is vald. month is zero based. date is not.

Parameters:
date - The day in the month.
month - The month.
year - The year.
Returns:
true: the date is valid; false: the date is NOT valid.