Java Utililty Methods SQL Date Get

List of utility methods to do SQL Date Get

Description

The list of methods to do SQL Date Get are organized into topic(s).

Method

DategetDate(ResultSet rs, int columnIndex)
get Date
Timestamp t = rs.getTimestamp(columnIndex);
return rs.wasNull() ? null : new Date(t.getTime());
DategetDate(ResultSet rs, int index)
get Date
if (rs.getTimestamp(index) != null) {
    return new Date(rs.getTimestamp(index).getTime());
return null;
DategetDate(ResultSet rs, String colName)
Returns a date value from a JDBC result set containing only the day part.
if (colName == null || colName.length() == 0 || rs == null) {
    throw new IllegalArgumentException("getDate: one or more parameters are null");
Date res = convertSQLDate2Date(rs.getDate(colName));
if (rs.wasNull()) {
    return null;
return res;
...
java.sql.DategetDate(ResultSet rs, String column)
get a date from ResultSet rs with name 'column'
java.sql.Date i = rs.getDate(column);
if (rs.wasNull())
    i = new java.sql.Date((long) 0);
return i;
DategetDate(ResultSet rs, String columnLabel)
get Date
return rs.getDate(columnLabel);
DategetDate(ResultSet rs, String columnName)
get a java.util.Date object from a result set column with sql type TIMESTAMP and given name
Timestamp ts = rs.getTimestamp(columnName);
if (ts == null) {
    return null;
return new Date(ts.getTime());
StringgetDate(String aDate, int dif)
get Date
java.sql.Date date = null;
try {
    date = java.sql.Date.valueOf(aDate);
} catch (Exception e) {
    System.err.println("Application log:Catch Exception in getDate()");
    System.err.println("aDate:" + aDate);
    System.err.println(e.getMessage());
    e.printStackTrace();
...
DategetDate(String date)
Converts a string to date.
return date != null ? java.sql.Date.valueOf(date) : null;
java.sql.DategetDate(String date)
This method converts date provided as a String into JDBC format.
try {
    if ((date == null) || (date.trim().length() == 0))
        return null;
    return new java.sql.Date(userDateFmt.parse(date).getTime());
} catch (ParseException e) {
    try {
        if ((date == null) || (date.trim().length() == 0))
            return null;
...
StringgetDate(String format)
get Date
String d = new SimpleDateFormat(format).format(Calendar.getInstance().getTime());
return d;