List of utility methods to do SQL Date Create
String | getCurrentDateString() get Current Date String return getCurrentDateString("yyyyMMdd"); |
Timestamp | getCurrentDateWithMinutePrecision() Gets the current date with minute precision. Calendar c = new GregorianCalendar(); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); Timestamp ts = new Timestamp(c.getTimeInMillis()); return ts; |
Timestamp | getCurrentDayStartDate(Date date) get Current Day Start Date Calendar rightNow = Calendar.getInstance(); rightNow.setTime(date); rightNow.set(Calendar.HOUR_OF_DAY, 0); rightNow.set(Calendar.MILLISECOND, 0); rightNow.set(Calendar.SECOND, 0); rightNow.set(Calendar.MINUTE, 0); rightNow.set(Calendar.MONTH, rightNow.get(Calendar.MONTH)); return new Timestamp(rightNow.getTimeInMillis()); ... |
java.sql.Date | getCurrentDBDate() get Current DB Date java.sql.Date current = new java.sql.Date(System.currentTimeMillis()); return current; |
java.sql.Date | getCurrentSQLDate() get Current SQL Date return dateToSqlDate(getCurrentDate());
|
java.sql.Date | getCurSQLDate() Get current date in form of java.sql.Date. return new java.sql.Date(new Date().getTime()); |
String | getCurSQLDateInString(String pstrDateFormat) Get current date in form of java.sql.Date and then convert it into String. String pstrDateTime = null; if ((pstrDateFormat != null) && (!pstrDateFormat.equals(""))) { java.util.Date curDateTime = new java.util.Date(); java.sql.Date curSqlDateTime = new java.sql.Date(curDateTime.getTime()); SimpleDateFormat sdf = new SimpleDateFormat(pstrDateFormat); pstrDateTime = sdf.format(curSqlDateTime); return pstrDateTime; ... |
java.sql.Date | getDataMaior(java.sql.Date data1, java.sql.Date data2) Compara 2 datas e retorna a maior, verificando os nulos. if (data1 == null) return data2; if (data2 == null) return data1; if (data1.after(data2)) { return data1; } else { return data2; ... |
Date | getDateAfter(Date date, Integer after) get Date After if (after == 0) { return new Date(date.getTime()); Date d = new Date(date.getTime()); for (int i = 0; i < after; i++) { d.setTime(d.getTime() + 86400000); return d; ... |
Date | getDateAfter(Date date, long offset) get Date After long offsettime = 1000 * 60 * 60 * 24 * offset; long t = date.getTime() + offsettime; return new Date(t); |