Java Utililty Methods SQL Date Create

List of utility methods to do SQL Date Create

Description

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

Method

DatecreateDate(int day, int month, int year)
create Date
Calendar cDate = Calendar.getInstance();
cDate.set(Calendar.DATE, day);
cDate.set(Calendar.MONTH, month);
cDate.set(Calendar.YEAR, year);
return new Date(cDate.getTimeInMillis());
DateFormatcreateDateFormater(int dataType)
create DateFormate depend on dataType.
SimpleDateFormat ret;
switch (dataType) {
case Types.TIME:
    ret = new SimpleDateFormat("HH:mm:ss");
    break;
case Types.TIMESTAMP:
    ret = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    break;
...
StringcreateFutureDate(java.sql.Date lmpDate, int offSet)
create Future Date
GregorianCalendar eddCal = new GregorianCalendar();
String DATE_FORMAT = "yyyy-MM-dd";
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(DATE_FORMAT);
sdf.setTimeZone(TimeZone.getDefault());
eddCal.setTime(java.sql.Date.valueOf(lmpDate.toString()));
eddCal.add(Calendar.DATE, offSet);
String newDate = sdf.format(eddCal.getTime());
return newDate;
...
StringcreateRecGetStatementsUpdate(String tip, String imeFirstCap)
create Rec Get Statements Update
StringBuilder sb = new StringBuilder();
if (tip.toLowerCase().contains("timestamp")) {
    sb.append("rec.get").append(imeFirstCap).append("() == null ? null : new java.sql.Timestamp(rec.get")
            .append(imeFirstCap).append("().getTime())");
} else if (tip.contains("Date")) {
    sb.append("rec.get").append(imeFirstCap).append("() == null ? null : new java.sql.Date(rec.get")
            .append(imeFirstCap).append("().getTime())");
} else if (tip.contains("Integer") || tip.contains("Long") || tip.contains("Float")
...
java.sql.DatecreateSqlDate(String dateStr)
create Sql Date
Date date = createDate(dateStr);
if (date != null) {
    return new java.sql.Date(date.getTime());
return null;
StatementcreateStreamingStatement(Connection conn, boolean update)
Returns a statement which tries its best to stream data.
int concurrency = update ? ResultSet.CONCUR_UPDATABLE : ResultSet.CONCUR_READ_ONLY;
DatabaseMetaData metadata = conn.getMetaData();
String driver = metadata.getDriverName();
if (driver == null) {
    driver = "";
if (POSTGRESQL_DRIVER_REGEX.matcher(driver).matches()) {
    logger_.info("Fixing PostgreSQL driver to stream results");
...
PreparedStatementcreateUpdateStatement(Connection conn, String databaseName, String[] fieldsToUpdate, String[] selectionFields)
create Update Statement
String updateString = createUpdateString(databaseName, fieldsToUpdate, selectionFields);
return conn.prepareStatement(updateString);
StringcurrentDate()
gets current time's string format like "yyyy-MM-dd"
return getDateFormat(now());
DatecurrentDate()
current Date
return new Timestamp(System.currentTimeMillis());
DatecurrentDate()
current Date
calendar.setTimeInMillis(currentTimeMillis());
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return new Date(calendar.getTimeInMillis());