List of utility methods to do SQL Date Create
java.util.Date | asDate(java.sql.Date sqlDate) as Date return sqlDate != null ? new java.util.Date(sqlDate.getTime()) : null; |
Timestamp | asDate(Object tsObj) as Date if (tsObj != null) { long tsLong = (tsObj instanceof Number) ? ((Number) tsObj).longValue() : Long.parseLong(tsObj.toString()); return new Timestamp(tsLong); return null; |
java.sql.Date | asSqlDate(Date date) Converts the given Date to a java.sql.Date . return new java.sql.Date(date.getTime()); |
java.sql.Date | asSqlDate(Date date) as Sql Date return date != null ? new java.sql.Date(date.getTime()) : null; |
java.sql.Date | asSqlDate(String date) Convert string as format "yyyy-MM-dd" to java.sql.Date. try { java.util.Date dt = new SimpleDateFormat("yyyy-MM-dd").parse(date); return new java.sql.Date(dt.getTime()); } catch (ParseException e) { throw new IllegalArgumentException(e); |
boolean | beforeNow(final Date d) before Now return d.before(new Date()); |
Date | beginOfDay(Date date) begin Of Day Calendar c = Calendar.getInstance();
c.setTime(date);
c.set(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
c.set(Calendar.MILLISECOND, 0);
return c.getTime();
|
java.sql.Date | castToSqlDate(Object value) cast To Sql Date if (value == null) { return null; if (value instanceof Calendar) { return new java.sql.Date(((Calendar) value).getTimeInMillis()); if (value instanceof java.sql.Date) { return (java.sql.Date) value; ... |
java.sql.Date | convert(Date date) Given a java.util.Date, return a java.sql.Date. if (date instanceof java.sql.Date) { return (java.sql.Date) date; } else { return new java.sql.Date(date.getTime()); |
Date | convertDate(java.sql.Date date) Converts a java.sql.Date to java.util.Date .
return new Date(date.getTime()); |