Java Utililty Methods SQL Date Get

List of utility methods to do SQL Date Get

Description

The list of methods to do SQL Date Get are organized into topic(s).

Method

longgetDateOrTime(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:
...
intgetDateParameter(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);
StringgetDatePath(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;
StringgetDatePath(java.util.Date fileDate)
Returns a directory structure based on the date supplied
return getDatePath(new java.sql.Timestamp(fileDate.getTime()));
DategetDateStart(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();
...
DategetDateTwo(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());
StringgetDateValue(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;
StringgetDateValue(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;
TimestampgetDateWithSpecifiedHourAndMinute(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());
StringgetDateYYMM(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;