Java SQL ResultSet Read getLocalDate(ResultSet rs, String columnName)

Here you can find the source of getLocalDate(ResultSet rs, String columnName)

Description

Get LocalDate instance from the ResultSet rs with columnName

License

RPL License

Parameter

Parameter Description
rs a parameter
columnName a parameter

Exception

Parameter Description
SQLException an exception

Return

null if the sqlDate retrieved from the result set is null.

Declaration

static public LocalDate getLocalDate(ResultSet rs, String columnName) throws SQLException 

Method Source Code

//package com.java2s;
/*/*  ww w.ja  v  a 2s  .co m*/
 * Unless explicitly acquired and licensed from Licensor under another license, the contents of
 * this file are subject to the Reciprocal Public License ("RPL") Version 1.5, or subsequent
 * versions as allowed by the RPL, and You may not copy or use this file in either source code
 * or executable form, except in compliance with the terms and conditions of the RPL
 *
 * All software distributed under the RPL is provided strictly on an "AS IS" basis, WITHOUT
 * WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, AND LICENSOR HEREBY DISCLAIMS ALL SUCH
 * WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
 * PARTICULAR PURPOSE, QUIET ENJOYMENT, OR NON-INFRINGEMENT. See the RPL for specific language
 * governing rights and limitations under the RPL.
 *
 * http://opensource.org/licenses/RPL-1.5
 *
 * Copyright 2012-2015 Open Justice Broker Consortium
 */

import java.sql.Date;

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

import java.time.LocalDate;

public class Main {
    /**
     * Get LocalDate instance from the ResultSet rs with columnName
     * @param rs
     * @param columnName
     * @return null if the sqlDate retrieved from the result set is null.
     * @throws SQLException
     */
    static public LocalDate getLocalDate(ResultSet rs, String columnName) throws SQLException {
        Date sqlDate = rs.getDate(columnName);
        return sqlDate == null ? null : sqlDate.toLocalDate();
    }
}

Related

  1. getList(ResultSet resultSet, String columnLabel, Class clazz)
  2. getList(ResultSet rs)
  3. getListFromRS(Class clazz, ResultSet rs)
  4. getListMapFromResultSet(ResultSet rs)
  5. getLocalDate(ResultSet res, String name)
  6. getMap(ResultSet resultSet)
  7. getMap(ResultSet resultSet)
  8. getMap(ResultSet rs, ResultSetMetaData metaData, int cols_len)
  9. getMetaData(ResultSet rs)