Expresso 5-5-0

com.jcorporate.expresso.core.misc
Class DateTime

java.lang.Object
  extended bycom.jcorporate.expresso.core.misc.DateTime

public class DateTime
extends Object

Version:
$Revision: 1.18 $ $Date: 2004/03/06 11:41:52 $
Author:
Michael Nash, Michael Rimov, Yves Henri Amaizo, David Lloyd

Constructor Summary
DateTime()
          Constructor
 
Method Summary
static String getDateForDB()
          Get a date field formatted for insertion into a database Value of the date is the current date author Yves Henri AMAIZO
static String getDateForDB(Date date)
          Get a time field formatted for insertion into a database author Yves Henri AMAIZO
static String getDateForDB(Date date, String context)
          Takes into account for the database context.
static String getDateForDB(int year, int mon, int day)
          Get a date field formatted for insertion into a database author Yves Henri AMAIZO
static String getDateFormatString(boolean dateOnly, Locale locale)
          Get the Date or DateTime format for a Locale.
static String getDateString()
          Return the current date as a formatted string
static String getDateString(Calendar now)
          Deprecated. Since Expresso 5.3 This function doesn't take into account database contexts or types of fields. Use getDateTimeForDB(Calendar.getTime()) instead.
static String getDateTimeForDB()
          Get a date/time field formatted for insertion into a database Value of the date/time is the current date and time
static String getDateTimeForDB(Date date)
          Get a date/time field formatted for insertion into a database (default context)
static String getDateTimeForDB(Date date, String context)
          Get a date/time field formatted for insertion into a database
static String getDateTimeForDB(int year, int month, int day, int hour, int min, int sec)
          Get a date/time field formatted for insertion into a database Value of the date/time is the current date and time
static String getDateTimeForDB(int year, int month, int day, int hour, int min, int sec, String context)
          Get a date/time field formatted for insertion into a database Value of the date/time is the current date and time
static String getDateTimeForDB(String dbContext)
          Get a date/time field formatted for insertion into a database Value of the date/time is the current date and time
static String getDateTimeString()
          Get a date/time string containing the current date and time, formatted for user readability
static String getDateTimeString(Date date)
          Get a date/time string for a given date and time, formatted for user readability
static String getTimeForDB()
          Get a time field formatted for insertion into a database Value of the time is the current time
static String getTimeForDB(Date date)
          Get a time field formatted for insertion into a database
static String getTimeForDB(Date date, String context)
          Takes into account for the database context.
static String getTimeForDB(int hour, int min, int sec)
          Get atime field formatted for insertion into a database
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateTime

public DateTime()
Constructor

Method Detail

getDateString

public static String getDateString()
Return the current date as a formatted string

Returns:
String The current date

getDateTimeForDB

public static String getDateTimeForDB()
                               throws DBException
Get a date/time field formatted for insertion into a database Value of the date/time is the current date and time

Returns:
String The formatted date time field
Throws:
DBException

getDateTimeForDB

public static String getDateTimeForDB(String dbContext)
                               throws DBException
Get a date/time field formatted for insertion into a database Value of the date/time is the current date and time

Parameters:
dbContext - the database context to which to format this for.
Returns:
String The formatted date time field
Throws:
DBException

getDateTimeForDB

public static String getDateTimeForDB(int year,
                                      int month,
                                      int day,
                                      int hour,
                                      int min,
                                      int sec,
                                      String context)
                               throws DBException
Get a date/time field formatted for insertion into a database Value of the date/time is the current date and time

Parameters:
year - integer year
month - integer month value
day - integer day value
hour - integer hour value
min - integer minutes value
sec - integer seconds value
context - the data context to format this date-time string for.
Returns:
String The formatted date time field
Throws:
DBException

getDateTimeForDB

public static String getDateTimeForDB(Date date,
                                      String context)
                               throws DBException
Get a date/time field formatted for insertion into a database

Parameters:
date - java.util.Date to format into a string for a database
context - the data context to format the string for.
Returns:
String The formatted date time field
Throws:
DBException

getDateString

public static String getDateString(Calendar now)
Deprecated. Since Expresso 5.3 This function doesn't take into account database contexts or types of fields. Use getDateTimeForDB(Calendar.getTime()) instead.

Format a Calendar object into a database capable timestamp.

Parameters:
now - Calendar Object that is to represent the date/time you wish to format for
Returns:
java.lang.String

getDateTimeForDB

public static String getDateTimeForDB(int year,
                                      int month,
                                      int day,
                                      int hour,
                                      int min,
                                      int sec)
                               throws DBException
Get a date/time field formatted for insertion into a database Value of the date/time is the current date and time

Parameters:
year - integer year
month - integer month value
day - integer day value
hour - integer hour value
min - integer minutes value
sec - integer seconds value
Returns:
String The formatted date time field
Throws:
DBException - upon error

getDateTimeForDB

public static String getDateTimeForDB(Date date)
                               throws DBException
Get a date/time field formatted for insertion into a database (default context)

Parameters:
date - the java.util.Date object to format for the database.
Returns:
String The formatted date time field
Throws:
DBException

getDateTimeString

public static String getDateTimeString()
                                throws DBException
Get a date/time string containing the current date and time, formatted for user readability

Returns:
String The formatted current date/time
Throws:
DBException

getDateTimeString

public static String getDateTimeString(Date date)
                                throws DBException
Get a date/time string for a given date and time, formatted for user readability

Parameters:
date - java.util.Date to format for the default database
Returns:
String The formatted current date/time
Throws:
DBException - upon error

getTimeForDB

public static String getTimeForDB()
                           throws DBException
Get a time field formatted for insertion into a database Value of the time is the current time

Returns:
String The formatted time field
Throws:
DBException - upon error

getTimeForDB

public static String getTimeForDB(int hour,
                                  int min,
                                  int sec)
                           throws DBException
Get atime field formatted for insertion into a database

Parameters:
hour - hours as an int
min - minutes as an int
sec - seconds as an int
Returns:
String The formatted time field
Throws:
DBException

getTimeForDB

public static String getTimeForDB(Date date)
                           throws DBException
Get a time field formatted for insertion into a database

Parameters:
date - the java.util.Date object to format for the default database
Returns:
String The formatted time field
Throws:
DBException

getTimeForDB

public static String getTimeForDB(Date date,
                                  String context)
                           throws DBException
Takes into account for the database context.

Parameters:
date - the java.util.Date object to format for
context - the data context to get the formatted string for.
Returns:
java.lang.String formatted for the specified context
Throws:
DBException

getDateForDB

public static String getDateForDB()
                           throws DBException
Get a date field formatted for insertion into a database Value of the date is the current date author Yves Henri AMAIZO

Returns:
String The formatted date field
Throws:
DBException

getDateForDB

public static String getDateForDB(int year,
                                  int mon,
                                  int day)
                           throws DBException
Get a date field formatted for insertion into a database author Yves Henri AMAIZO

Parameters:
year - The year as an integer. ex: 1999
mon - The month as an integer [0-11]
day - of month The day of the month [1-31 variable]
Returns:
String The formatted date field
Throws:
DBException

getDateForDB

public static String getDateForDB(Date date)
                           throws DBException
Get a time field formatted for insertion into a database author Yves Henri AMAIZO

Parameters:
date - The java.util.Date to format
Returns:
String The formatted date field
Throws:
DBException

getDateForDB

public static String getDateForDB(Date date,
                                  String context)
                           throws DBException
Takes into account for the database context. author Yves Henri AMAIZO

Parameters:
date - The java.util.Date to format
context - The data context to format for
Returns:
String formatted for the specified database
Throws:
DBException

getDateFormatString

public static String getDateFormatString(boolean dateOnly,
                                         Locale locale)
Get the Date or DateTime format for a Locale. For each of the date format characters (M,d,y,h,H,k,K,m,s), a lookup is made in the message bundle for the data format wanted.
For example, if DateFormat.getDateInstance(DateFormat.SHORT,locale) returns "M/dd/yy" and you wanted to show "mm/dd/yyyy" to the user, the resource bundle com.jcorporate.expresso.core.MessageBundle would need
   datetime.format.MM = mm
   datetime.format.dd = dd
   datetime.format.yy = yyyy
 

The entries are cached because the DateFormat calls are VERY expensive. author David Lloyd

Parameters:
dateOnly - True if this is to get a date only format (m/d/yy) versus DateTime (m/d/yy h:m:s)
locale - The locale to get the format for. This may not be null
Returns:
String formatted for the date

Expresso 5-5-0

Please see www.jcorporate.com for information about new Expresso releases.