Java SQL Date Get getDate(ResultSet res, String name)

Here you can find the source of getDate(ResultSet res, String name)

Description

Returns the values of the specified column as a Date.

License

MIT License

Parameter

Parameter Description
res a result set.
name a name of the column.

Exception

Parameter Description
SQLException if an error occurs.

Return

the value of the column.

Declaration

public static Date getDate(ResultSet res, String name) throws SQLException 

Method Source Code

//package com.java2s;
/*//from  w w w. j  a  v  a2  s  .c o  m
 * Copyright (c) 2015-2016 QuartzDesk.com.
 * Licensed under the MIT license (https://opensource.org/licenses/MIT).
 */

import java.sql.ResultSet;
import java.sql.SQLException;

import java.util.Date;

public class Main {
    /**
     * Returns the values of the specified column as a Date. If the column
     * value is null, this method returns null.
     *
     * @param res  a result set.
     * @param name a name of the column.
     * @return the value of the column.
     * @throws SQLException if an error occurs.
     */
    public static Date getDate(ResultSet res, String name) throws SQLException {
        java.sql.Date v = res.getDate(name);
        return res.wasNull() ? null : new Date(v.getTime());
    }
}

Related

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