Java SQL Date Get getDate(ResultSet rs, int colNum)

Here you can find the source of getDate(ResultSet rs, int colNum)

Description

get Date

License

Apache License

Declaration

public static Date getDate(ResultSet rs, int colNum) throws SQLException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

import java.sql.Timestamp;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;

public class Main {
    public static final Calendar tzUTC = Calendar.getInstance(TimeZone.getTimeZone("UTC"));

    public static Date getDate(ResultSet rs, int colNum) throws SQLException {
        Timestamp ts = rs.getTimestamp(colNum, tzUTC); // column is TIMESTAMPTZ
        return ts != null ? new Date(ts.getTime()) : null;
    }//  w w w  . j ava2  s . c  om
}

Related

  1. getDate(Object value)
  2. getDate(Object value, int columnType)
  3. getDate(ResultSet aResultSet, String aColumnName)
  4. getDate(ResultSet res, String name)
  5. getDate(ResultSet resultSet, String columnName)
  6. getDate(ResultSet rs, int columnIndex)
  7. getDate(ResultSet rs, int index)
  8. getDate(ResultSet rs, String colName)
  9. getDate(ResultSet rs, String column)