mirror of
https://github.com/moparisthebest/JdbcMapper
synced 2024-12-21 23:08:52 -05:00
Slight re-factor of ResultSetUtil.java
This commit is contained in:
parent
b861d63115
commit
db1de1c43f
@ -71,13 +71,16 @@ public class ResultSetUtil {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T extends Enum<T>> T getEnum(final ResultSet _resultSet, final int index, final Class<T> enumType) throws SQLException {
|
||||||
|
final String name = _resultSet.getString(index);
|
||||||
|
return name == null ? null : Enum.valueOf(enumType, name);
|
||||||
|
}
|
||||||
|
|
||||||
public static java.util.Date getUtilDate(final ResultSet _resultSet, final int index) throws SQLException {
|
public static java.util.Date getUtilDate(final ResultSet _resultSet, final int index) throws SQLException {
|
||||||
// convert explicity to java.util.Date
|
// convert explicity to java.util.Date
|
||||||
// 12918 | knex does not return java.sql.Date properly from web service
|
// 12918 | knex does not return java.sql.Date properly from web service
|
||||||
java.sql.Timestamp ts = _resultSet.getTimestamp(index);
|
final java.sql.Timestamp ts = _resultSet.getTimestamp(index);
|
||||||
if (null == ts)
|
return ts == null ? null : new java.util.Date(ts.getTime());
|
||||||
return null;
|
|
||||||
return new java.util.Date(ts.getTime());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static java.util.Date getUtilDate(final ResultSet _resultSet, final int index, final Calendar _cal) throws SQLException {
|
public static java.util.Date getUtilDate(final ResultSet _resultSet, final int index, final Calendar _cal) throws SQLException {
|
||||||
@ -85,17 +88,15 @@ public class ResultSetUtil {
|
|||||||
return getUtilDate(_resultSet, index);
|
return getUtilDate(_resultSet, index);
|
||||||
// convert explicity to java.util.Date
|
// convert explicity to java.util.Date
|
||||||
// 12918 | knex does not return java.sql.Date properly from web service
|
// 12918 | knex does not return java.sql.Date properly from web service
|
||||||
java.sql.Timestamp ts = _resultSet.getTimestamp(index, _cal);
|
final java.sql.Timestamp ts = _resultSet.getTimestamp(index, _cal);
|
||||||
if (null == ts)
|
return ts == null ? null : new java.util.Date(ts.getTime());
|
||||||
return null;
|
|
||||||
return new java.util.Date(ts.getTime());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Calendar getCalendar(final ResultSet _resultSet, final int index) throws SQLException {
|
public static Calendar getCalendar(final ResultSet _resultSet, final int index) throws SQLException {
|
||||||
java.sql.Timestamp ts = _resultSet.getTimestamp(index);
|
final java.sql.Timestamp ts = _resultSet.getTimestamp(index);
|
||||||
if (null == ts)
|
if (null == ts)
|
||||||
return null;
|
return null;
|
||||||
Calendar c = Calendar.getInstance();
|
final Calendar c = Calendar.getInstance();
|
||||||
c.setTimeInMillis(ts.getTime());
|
c.setTimeInMillis(ts.getTime());
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
@ -103,19 +104,14 @@ public class ResultSetUtil {
|
|||||||
public static Calendar getCalendar(final ResultSet _resultSet, final int index, final Calendar _cal) throws SQLException {
|
public static Calendar getCalendar(final ResultSet _resultSet, final int index, final Calendar _cal) throws SQLException {
|
||||||
if(_cal == null)
|
if(_cal == null)
|
||||||
return getCalendar(_resultSet, index);
|
return getCalendar(_resultSet, index);
|
||||||
java.sql.Timestamp ts = _resultSet.getTimestamp(index, _cal);
|
final java.sql.Timestamp ts = _resultSet.getTimestamp(index, _cal);
|
||||||
if (null == ts)
|
if (null == ts)
|
||||||
return null;
|
return null;
|
||||||
Calendar c = (Calendar) _cal.clone();
|
final Calendar c = (Calendar) _cal.clone();
|
||||||
c.setTimeInMillis(ts.getTime());
|
c.setTimeInMillis(ts.getTime());
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends Enum<T>> T getEnum(final ResultSet _resultSet, final int index, final Class<T> enumType) throws SQLException {
|
|
||||||
final String name = _resultSet.getString(index);
|
|
||||||
return name == null ? null : Enum.valueOf(enumType, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
//IFJAVA8_START
|
//IFJAVA8_START
|
||||||
|
|
||||||
public static Instant getInstant(final ResultSet _resultSet, final int index) throws SQLException {
|
public static Instant getInstant(final ResultSet _resultSet, final int index) throws SQLException {
|
||||||
|
Loading…
Reference in New Issue
Block a user