Java Timestamp Create getTimestamp(ResultSet rs, String strColName)

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

Description

Auxiliary method to avoid problems with null timestamp values

License

Open Source License

Parameter

Parameter Description
rs a parameter
strColName a parameter

Exception

Parameter Description
SQLException an exception

Declaration

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

Method Source Code

//package com.java2s;
/**//from www  .  ja v  a 2  s .c  om
 SiBBr API - Interface p?blica de acesso aos registros de ocorr?ncia
Copyright (C) 2015  SiBBr - Sistema de Informa??o sobre a Biodiversidade Brasileira
    
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
    
This program 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 General Public License for more details.
 */

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

public class Main {
    /**
     * Auxiliary method to avoid problems with null timestamp values
     * 
     * @param rs
     * @param strColName
     * @return
     * @throws SQLException
     */
    public static Timestamp getTimestamp(ResultSet rs, String strColName) throws SQLException {
        Timestamp value = rs.getTimestamp(strColName);
        return rs.wasNull() ? null : value;
    }
}

Related

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