Here you can find the source of getDbDateValue(ResultSet rs, String columnName)
ResultSet
and a column name containing a [possibly null] Date
, this method attempts to fetch the date from the result set.
Parameter | Description |
---|---|
rs | the result set to search |
columnName | the desired column name containing data of type <code>Date</code> |
public static Date getDbDateValue(ResultSet rs, String columnName)
//package com.java2s; //License from project: Apache License import java.sql.ResultSet; import java.sql.SQLException; import java.util.Date; public class Main { /**//from w w w .j a v a2s .co m * Given a <code>ResultSet</code> and a column name containing a [possibly * null] <code>Date</code>, this method attempts to fetch the date from the * result set. If successful, the value is returned * as a <code>Date</code>; otherwise, null <code>Date</code> is returned. * @param rs the result set to search * @param columnName the desired column name containing data of type <code>Date</code> * @return the value, if successful; null otherwise */ public static Date getDbDateValue(ResultSet rs, String columnName) { Date retVal = null; try { Object o = rs.getObject(columnName); if (o != null) retVal = (Date) o; } catch (SQLException e) { throw new RuntimeException("Unable to get result set Date value for column '" + columnName + "'"); } return retVal; } }