List of utility methods to do SQL Date Get
java.sql.Date | getDate(final int year, final int month, final int day) Creates a java.sql.Date for a specified date in the UTC time zone. final Calendar cal = new GregorianCalendar(UTC); cal.clear(); cal.set(year, month - 1, day); return new java.sql.Date(cal.getTimeInMillis()); |
Timestamp | getDate(final String value) get Date if (value.equalsIgnoreCase("NOW")) return new Timestamp(Calendar.getInstance().getTime().getTime()); else return Timestamp.valueOf(value); |
Date | getDate(Map get Date return (Date) m.get(key);
|
Date | getDate(Object object) get Date Date date = null; try { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd hh:mm"); SimpleDateFormat format3 = new SimpleDateFormat("yyyy-MM-dd"); if (object instanceof String) { try { date = format.parse((String) object); ... |
java.sql.Date | getDate(Object value) Convert an Object to a Date, without an Exception try { return toDate(value); } catch (ParseException pe) { pe.printStackTrace(); return null; |
java.sql.Date | getDate(Object value, int columnType) get Date if (value == null) { return null; switch (columnType) { case java.sql.Types.DATE: { long sec = ((java.sql.Date) value).getTime(); return new java.sql.Date(sec); case java.sql.Types.TIMESTAMP: { long sec = ((java.sql.Timestamp) value).getTime(); return new java.sql.Date(sec); case java.sql.Types.CHAR: case java.sql.Types.VARCHAR: case java.sql.Types.LONGVARCHAR: case java.sql.Types.NCHAR: case java.sql.Types.NVARCHAR: case java.sql.Types.LONGNVARCHAR: { try { DateFormat df = DateFormat.getDateInstance(); return ((java.sql.Date) (df.parse(value.toString()))); } catch (ParseException ex) { throw new Exception("date conversion failed. (" + value.toString().trim() + "/" + columnType + ")"); default: { throw new Exception("date conversion failed. (" + value.toString().trim() + "/" + columnType + ")"); |
Date | getDate(ResultSet aResultSet, String aColumnName) Returns the specified column of the result set as a Date .
Timestamp timestamp = aResultSet.getTimestamp(aColumnName); return ((timestamp == null) || aResultSet.wasNull()) ? null : new Date(timestamp.getTime()); |
Date | getDate(ResultSet res, String name) Returns the values of the specified column as a Date. java.sql.Date v = res.getDate(name); return res.wasNull() ? null : new Date(v.getTime()); |
Date | getDate(ResultSet resultSet, String columnName) Returns a date value using a given SQL result set and column name. Date value = null; if (resultSet != null && columnName != null) { value = resultSet.getDate(columnName); return value; |
Date | getDate(ResultSet rs, int colNum) get Date Timestamp ts = rs.getTimestamp(colNum, tzUTC); return ts != null ? new Date(ts.getTime()) : null; |