org.objectweb.telosys.util
Class DateUtil

java.lang.Object
  extended byorg.objectweb.telosys.util.DateUtil

public final class DateUtil
extends java.lang.Object

Utility class for DATE operations ( set of static methods )


Method Summary
static java.lang.String dateISO(java.util.Date date)
          Returns the given date as an ISO date string ( "YYYY-MM-DD" )
static java.lang.String dateTimeISO(java.util.Date date)
          Returns the given date as an ISO date and time string ( "YYYY-MM-DD HH:MM:SS" )
static java.lang.String format(java.util.Date date, java.lang.String sFormat)
          Format the given date using the given format
static java.lang.String format(int iDay, int iMonth, int iYear)
          Format the given day, month and year ( in ISO format )
static java.lang.String format(int iDay, int iMonth, int iYear, java.lang.String sFormat)
          Format the given day, month and year
static int getDay(java.sql.Date date)
          Returns the day of the month for the given date
static int getMonth(java.sql.Date date)
          Returns the month of the given date
static java.sql.Date getSqlDate(int iDay, int iMonth, int iYear)
          Returns a java.sql.Date instance for the given day, month and year
static java.util.Date getUtilDate(int iDay, int iMonth, int iYear)
          Returns a standard java.util.Date instance for the given day, month and year
static int getYear(java.sql.Date date)
          Returns the year of the given date
static java.util.Date parseDate(java.lang.String sDate)
          Parse the given date ( supposed to be in ISO format : "YYYY-MM-DD" )
static java.util.Date parseDateTime(java.lang.String sDateTime)
          Parse the given date & time ( supposed to be in ISO format : "YYYY-MM-DD HH:MM:SS" )
static java.util.Date parseTime(java.lang.String sTime)
          Parse the given time ( supposed to be in ISO format : "HH:MM:SS" )
static java.lang.String timeISO(java.util.Date date)
          Returns the given date as an ISO time string ( "HH:MM:SS" )
static java.sql.Date todaySqlDate()
          Returns the current date as java.sql.Date
static java.lang.String todayString(java.lang.String sFormat)
          Returns the current date as a String formated with the given format
static java.util.Date todayUtilDate()
          Returns the current date as java.util.Date
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

todaySqlDate

public static java.sql.Date todaySqlDate()
Returns the current date as java.sql.Date

Returns:
java.sql.Date :

todayUtilDate

public static java.util.Date todayUtilDate()
Returns the current date as java.util.Date

Returns:
java.util.Date :

todayString

public static java.lang.String todayString(java.lang.String sFormat)
Returns the current date as a String formated with the given format

Parameters:
sFormat - :
Returns:
String :

format

public static java.lang.String format(int iDay,
                                      int iMonth,
                                      int iYear,
                                      java.lang.String sFormat)
Format the given day, month and year

Parameters:
iDay - the day ( 1 to 31 )
iMonth - the month ( 1 to 12 )
iYear - the year
sFormat - the format string usable to build a SimpleDateFormat
Returns:
: the formated date ( using the given format )

format

public static java.lang.String format(int iDay,
                                      int iMonth,
                                      int iYear)
Format the given day, month and year ( in ISO format )

Parameters:
iDay - the day ( 1 to 31 )
iMonth - ( 1 to 12 )
iYear - the year
Returns:
: the formated date ( using the default ISO format )

format

public static java.lang.String format(java.util.Date date,
                                      java.lang.String sFormat)
Format the given date using the given format

Parameters:
date -
sFormat -
Returns:
Since:
1.0.3

getSqlDate

public static java.sql.Date getSqlDate(int iDay,
                                       int iMonth,
                                       int iYear)
Returns a java.sql.Date instance for the given day, month and year

Parameters:
iDay - the day ( 1 to 31 )
iMonth - the month ( 1 to 12 )
iYear - the year
Returns:
java.sql.Date :

getUtilDate

public static java.util.Date getUtilDate(int iDay,
                                         int iMonth,
                                         int iYear)
Returns a standard java.util.Date instance for the given day, month and year

Parameters:
iDay - the day ( 1 to 31 )
iMonth - the month ( 1 to 12 )
iYear - the year
Returns:
java.util.Date :

getDay

public static int getDay(java.sql.Date date)
Returns the day of the month for the given date

Parameters:
date -
Returns:
int : 0 to 31

getMonth

public static int getMonth(java.sql.Date date)
Returns the month of the given date

Parameters:
date - :
Returns:
int : 1 to 12

getYear

public static int getYear(java.sql.Date date)
Returns the year of the given date

Parameters:
date - :
Returns:
int :

dateISO

public static java.lang.String dateISO(java.util.Date date)
Returns the given date as an ISO date string ( "YYYY-MM-DD" )

Parameters:
date -
Returns:
the date in ISO string format ( or "" if null )

timeISO

public static java.lang.String timeISO(java.util.Date date)
Returns the given date as an ISO time string ( "HH:MM:SS" )

Parameters:
date -
Returns:
the time in ISO string format ( or "" if null )

dateTimeISO

public static java.lang.String dateTimeISO(java.util.Date date)
Returns the given date as an ISO date and time string ( "YYYY-MM-DD HH:MM:SS" )

Parameters:
date -
Returns:
the date and time in ISO string format ( or "" if null )

parseDate

public static java.util.Date parseDate(java.lang.String sDate)
Parse the given date ( supposed to be in ISO format : "YYYY-MM-DD" )

Parameters:
sDate -
Returns:
date or null if the given string is null or void
Throws:
TelosysRuntimeException - if the date is invalid
Since:
1.0.2

parseTime

public static java.util.Date parseTime(java.lang.String sTime)
Parse the given time ( supposed to be in ISO format : "HH:MM:SS" )

Parameters:
sTime -
Returns:
time or null if the given string is null or void
Throws:
TelosysRuntimeException - if the time is invalid
Since:
1.0.2

parseDateTime

public static java.util.Date parseDateTime(java.lang.String sDateTime)
Parse the given date & time ( supposed to be in ISO format : "YYYY-MM-DD HH:MM:SS" )

Parameters:
sDateTime -
Returns:
date with time or null if the given string is null or void
Throws:
TelosysRuntimeException - if the time is invalid
Since:
1.0.2