Java SQL Date Get getDateFromResultSet(ResultSet rset, Enum field)

Here you can find the source of getDateFromResultSet(ResultSet rset, Enum field)

Description

get Date From Result Set

License

Open Source License

Declaration

public static Date getDateFromResultSet(ResultSet rset, Enum field) throws SQLException 

Method Source Code

//package com.java2s;
/**//from   w  w w . j  a  v a2  s . com
 Copyright (c) 2013, Amit Lieberman
All rights reserved.
    
           GNU LESSER GENERAL PUBLIC LICENSE
               Version 3, 29 June 2007
    
 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.
    
    
  This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License
    
 * Created with love
 * User: shpandrak
 * Date: 10/20/12
 * Time: 10:37
 */

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;

public class Main {
    public static Date getDateFromResultSet(ResultSet rset, Enum field) throws SQLException {
        return getDateFromResultSet(rset, field.name());
    }

    public static Date getDateFromResultSet(ResultSet rset, String column) throws SQLException {
        long timestamp = rset.getLong(column);
        if (timestamp == 0)
            return null;
        return new Date(timestamp);
    }

    public static Date getDateFromResultSet(ResultSet rset, int column) throws SQLException {
        long timestamp = rset.getLong(column);
        if (timestamp == 0)
            return null;
        return new Date(timestamp);
    }
}

Related

  1. getDateDiscrepancy(String startDate, String endDate)
  2. getDateEnd(Date date)
  3. getDateForStr(String str)
  4. getDateFromISODateString(String isoDate)
  5. getDateFromLong(ResultSet resultSet, int index)
  6. getDateFromRTGSDateString(String iobDate)
  7. getDateFromTimestamp(Timestamp timestamp)
  8. getDateFromYMD(Date ymd)
  9. getDateInput(String prompt)