Java Timestamp Create getTimestamp(ResultSet rs, String colName)

Here you can find the source of getTimestamp(ResultSet rs, String colName)

Description

Returns the TimeStamp value for the specified column

License

Open Source License

Parameter

Parameter Description
rs a parameter
colName a parameter

Exception

Parameter Description
SQLException an exception

Declaration

public final static Timestamp getTimestamp(ResultSet rs, String colName) throws SQLException 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * This file is part of ISPyB./*from w w w  .ja v  a2 s .co  m*/
 * 
 * ISPyB is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * ISPyB is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with ISPyB.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Contributors : S. Delageniere, R. Leal, L. Launer, K. Levik, S. Veyrier, P. Brenchereau, M. Bodin, A. De Maria Antolinos
 ******************************************************************************/

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

import java.sql.Timestamp;

public class Main {
    /**
     * Returns the TimeStamp value for the specified column
     * 
     * @param rs
     * @param colName
     * @return
     * @throws SQLException
     */
    public final static Timestamp getTimestamp(ResultSet rs, String colName) throws SQLException {
        if (colName == null || colName.length() == 0 || rs == null) {
            throw new IllegalArgumentException("getTimestamp: one or more parameters are null");
        }
        Timestamp timestamp = rs.getTimestamp(colName);
        if (rs.wasNull()) {
            return null;
        }
        return timestamp;
    }
}

Related

  1. getTimestamp(java.util.Date utilDate)
  2. getTimestamp(long time)
  3. getTimestamp(Object o)
  4. getTimestamp(Object value)
  5. getTimestamp(Object value, int columnType)
  6. getTimestamp(ResultSet rs, String strColName)
  7. getTimestamp(String date, String time)
  8. getTimestamp(String dateStr)
  9. getTimestamp(String dateString, String format)