List of utility methods to do SQL Date From
String | getDateTime() get Date Time return new Timestamp(System.currentTimeMillis()).toString().substring(0, 19); |
String | getDateTime() get Date Time SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return sdf.format(new Date()); |
Date | getDateTime(final int year, final int month, final int day, final int hour, final int minute, final int second) Creates a java.util.Date for a specified date time in the UTC time zone. final Calendar cal = new GregorianCalendar(UTC); cal.clear(); cal.set(year, month - 1, day, hour, minute, second); return cal.getTime(); |
java.util.Date | getDateTime(Object value) Convert an Object to a DateTime, without an Exception try { return toDateTime(value); } catch (ParseException pe) { pe.printStackTrace(); return null; |
Date | toDate(Calendar cal)toDate (cal): convert Calendar to Date
if (cal == null) return null; return cal.getTime(); |
java.sql.Date | toDate(int value) to Date int d = value % 32; value >>>= 5; int m = value % 16; int y = value >> 4; Calendar cal = Calendar.getInstance(); cal.clear(); cal.set(y, m - 1, d); return new java.sql.Date(cal.getTimeInMillis()); ... |
Date | toDate(java.sql.Date sqlDate) to Date return (sqlDate == null ? null : new Date(sqlDate.getTime())); |
Date | toDate(java.util.Date date) Converts a java.util.Date into an java.sql.Date. return date == null ? null : new Date(date.getTime()); |
Date | toDate(Object date) Convert the argument date string to a vanilla java.util.Date. if (date == null) return null; if (date instanceof java.sql.Timestamp) { java.sql.Timestamp ts = (java.sql.Timestamp) date; long millis = ts.getTime(); return new Date(millis); if (date instanceof java.sql.Date) { ... |
Date | toDate(Object o) to Date Date result = null; if (o instanceof Timestamp) { result = o != null ? new Date(((Timestamp) o).getTime()) : null; return result; |