List of utility methods to do SQL Date Get
long | getDateOrTime(int colType, Object o) get Date Or Time switch (colType) { case Types.DATE: java.sql.Date dt = (java.sql.Date) o; return dt.getTime(); case Types.TIME: java.sql.Time t = (java.sql.Time) o; return t.getTime(); case Types.TIMESTAMP: ... |
int | getDateParameter(java.sql.Date date, int param) get Date Parameter if (date == null) { return -1; cal.setTime(new java.util.Date(date.getTime())); return cal.get(param); |
String | getDatePath(java.sql.Timestamp fileDate) get Date Path SimpleDateFormat formatter1 = new SimpleDateFormat("yyyy"); String datePathToUse1 = formatter1.format(fileDate); SimpleDateFormat formatter2 = new SimpleDateFormat("MMdd"); String datePathToUse2 = formatter2.format(fileDate); return datePathToUse1 + fs + datePathToUse2 + fs; |
String | getDatePath(java.util.Date fileDate) Returns a directory structure based on the date supplied return getDatePath(new java.sql.Timestamp(fileDate.getTime())); |
Date | getDateStart(Date date) get Date Start Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, (date.getYear() + 1900));
calendar.set(Calendar.MONTH, date.getMonth());
calendar.set(Calendar.DATE, date.getDate());
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
return calendar.getTime();
...
|
Date | getDateTwo(Date date) get Date Two Calendar calendar = Calendar.getInstance(); calendar.setTime(date); int day = calendar.get(Calendar.DATE); calendar.set(Calendar.DATE, day); return getSqlDate(calendar.getTime()); |
String | getDateValue(ResultSet result, String strField, String strDateFormat) get Date Value String strValueReturn; Date date = result.getDate(strField); if (result.wasNull()) { strValueReturn = ""; } else { SimpleDateFormat formatter = new SimpleDateFormat(strDateFormat); strValueReturn = formatter.format(date); return strValueReturn; |
String | getDateValue(ResultSet result, String strField, String strDateFormat) get Date Value String strValueReturn; Date date = result.getDate(strField); if (result.wasNull()) { strValueReturn = ""; } else { SimpleDateFormat formatter = new SimpleDateFormat(strDateFormat); strValueReturn = formatter.format(date); return strValueReturn; |
Timestamp | getDateWithSpecifiedHourAndMinute(Date targetDate, int hour, int minute) get Date With Specified Hour And Minute Calendar c = Calendar.getInstance(); c.setTime(targetDate); c.set(Calendar.HOUR_OF_DAY, hour); c.set(Calendar.MINUTE, minute); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); return new Timestamp(c.getTimeInMillis()); |
String | getDateYYMM(java.sql.Timestamp ts) given timestamp object and return string format of YYMM String oracleDate = ""; if (ts != null) { oracleDate = ts.toString().substring(2, 4) + ts.toString().substring(5, 7); return oracleDate; |