List of utility methods to do SQL Date From
java.sql.Date | toSqlDate(Date date) to Sql Date return new java.sql.Date(date.getTime()); |
Timestamp | toSqlDate(Date dt) to Sql Date if (dt == null) { return null; return new Timestamp(dt.getTime()); |
java.sql.Date | toSqlDate(final Date date) to Sql Date return new java.sql.Date(date.getTime()); |
java.sql.Date | toSqlDate(final String _text, final String _dateFormat) Convert a string into a java.sql.Date .
return toSqlDate(toDate(_text, _dateFormat));
|
java.util.Date | toSQLDate(java.util.Date date) Returns the specified object as an instance of an SQL-compatible subclass of java.util.Date : either java.sql.Date or java.sql.Timestamp , depending on the presence of the time part. Calendar cal = Calendar.getInstance(); cal.setTime(date); long msec = cal.getTimeInMillis(); boolean has_time_part = cal.get(Calendar.HOUR_OF_DAY) + cal.get(Calendar.MINUTE) + cal.get(Calendar.SECOND) + cal.get(Calendar.MILLISECOND) != 0; return has_time_part ? (java.util.Date) new java.sql.Timestamp(msec) : new java.sql.Date(msec); |
java.sql.Date | toSQLDate(java.util.Date date) to SQL Date return new java.sql.Date(date.getTime()); |
java.sql.Date | toSqlDate(java.util.Date date) Convert a java.util.Date object to a java.sql.Date object. Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return new java.sql.Date(cal.getTimeInMillis()); |
java.sql.Date | toSQLDate(Object object, Object oDefault) to SQL Date if (object == null) { if (oDefault == null) return null; return toSQLDate(oDefault, null); if (object instanceof java.sql.Date) { return (java.sql.Date) object; if (object instanceof java.util.Date) { return new java.sql.Date(((java.util.Date) object).getTime()); if (object instanceof java.util.Calendar) { return new java.sql.Date(((java.util.Calendar) object).getTimeInMillis()); if (object instanceof Long) { return new java.sql.Date(((Long) object).longValue()); if (object instanceof Number) { int iDate = ((Number) object).intValue(); if (iDate < 10000) return toSQLDate(oDefault, null); return new java.sql.Date(intToLongDate(iDate)); if (object instanceof Collection) { return toSQLDate(getFirst(object), oDefault); if (object.getClass().isArray()) { return toSQLDate(getFirst(object), oDefault); if (object instanceof Map) { return toSQLDate(oDefault, null); String sValue = object.toString(); if (sValue == null || sValue.length() == 0) return toSQLDate(oDefault, null); String sDate = normalizeStringDate(sValue); if (sDate == null) return toSQLDate(oDefault, null); return new java.sql.Date(stringToLongDate(sDate)); |
java.sql.Date | toSqlDate(String date) Converts a date String into a java.sql.Date java.util.Date newDate = toDate(date, "00:00:00"); if (newDate != null) return new java.sql.Date(newDate.getTime()); else return null; |
java.sql.Date | toSqlDate(String date) to Sql Date java.util.Date newDate = toDate(date, "00:00:00"); if (newDate == null) return null; return new java.sql.Date(newDate.getTime()); |