Java SQL Date Get getDate(ResultSet aResultSet, String aColumnName)

Here you can find the source of getDate(ResultSet aResultSet, String aColumnName)

Description

Returns the specified column of the result set as a Date.

License

Open Source License

Parameter

Parameter Description
aResultSet a parameter
aColumnName a parameter

Exception

Parameter Description
SQLException an exception

Declaration

public static Date getDate(ResultSet aResultSet, String aColumnName)
        throws SQLException 

Method Source Code

//package com.java2s;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.Date;

public class Main {
    /**//from  www .j a  va  2s. com
     * Returns the specified column of the result set as a <code>Date</code>.
     *
     * @param aResultSet
     * @param aColumnName
     * @throws SQLException
     */
    public static Date getDate(ResultSet aResultSet, String aColumnName)
            throws SQLException {
        Timestamp timestamp = aResultSet.getTimestamp(aColumnName);
        return ((timestamp == null) || aResultSet.wasNull()) ? null
                : new Date(timestamp.getTime());
    }
}

Related

  1. getDate(final String value)
  2. getDate(Map m, String key)
  3. getDate(Object object)
  4. getDate(Object value)
  5. getDate(Object value, int columnType)
  6. getDate(ResultSet res, String name)
  7. getDate(ResultSet resultSet, String columnName)
  8. getDate(ResultSet rs, int colNum)
  9. getDate(ResultSet rs, int columnIndex)