List of utility methods to do SQL Time
Date | extractTime(Date date) Returns a date with "zero" date. return extractTime(date, getDefaultTimeZone());
|
void | getCalTime(Time startTime, Calendar cal) get Cal Time int year = cal.get(Calendar.YEAR); int month = cal.get(Calendar.MONTH); int day = cal.get(Calendar.DAY_OF_MONTH); cal.setTime(startTime); int hour = cal.get(Calendar.HOUR_OF_DAY); int min = cal.get(Calendar.MINUTE); int sec = cal.get(Calendar.SECOND); cal.set(year, month, day, hour, min, sec); ... |
Class> | getClassForSqlType(String sqlType, Class extends java.util.Date> dateTimeClass) Returns the Java class for a given SQL type. sqlType = sqlType.toUpperCase(); sqlType = sqlType.split(" ")[0].trim(); if (SQL_TYPES.containsKey(sqlType)) { sqlType = SQL_TYPES.get(sqlType); Class<?> mappedClass = null; for (Class<?> clazz : SUPPORTED_TYPES.keySet()) { if (SUPPORTED_TYPES.get(clazz).equalsIgnoreCase(sqlType)) { ... |
long | getClosestIDByTime(Connection con, String table, long time) get Closest ID By Time String sql = "SELECT `id` FROM `" + table + "` WHERE `created_1` < " + time + " ORDER BY `id` DESC LIMIT 1;"; CallableStatement stmt = con.prepareCall(sql); ResultSet rs = stmt.executeQuery(); rs.next(); long closestId = rs.getLong(1); rs.close(); return closestId; ... |
String | getDateTimeValue(ResultSet result, String strField, String strDateFormat) get Date Time Value String strValueReturn; Timestamp timestamp = result.getTimestamp(strField); if (result.wasNull()) { strValueReturn = ""; } else { SimpleDateFormat formatter = new SimpleDateFormat(strDateFormat); strValueReturn = formatter.format(timestamp); return strValueReturn; |
String | getDBTime(String yyyyMMddHHmmss) get DB Time String d = ""; try { SimpleDateFormat temp = new SimpleDateFormat("yyyyMMddHHmmss"); d = new java.sql.Timestamp(temp.parse(yyyyMMddHHmmss).getTime()).toString(); } catch (Exception ex) { ex.printStackTrace(); return d; ... |
String | getFormatDateTimeDesc(long longDate) get Format Date Time Desc return new Timestamp(longDate).toString().substring(0, 19); |
java.util.Date | getFullDateTime(ResultSet rs, String column) Returns the value of a DATETIME column in the current row of an SQL result set, formatted as a date. return convertDateTimeString(rs.getString(column));
|
Timestamp | getFutureTime(int month) get Future Time Calendar c = Calendar.getInstance(); c.add(Calendar.MONTH, month); return new Timestamp(c.getTimeInMillis()); |
Timestamp | getGrandfatheredTime() get Grandfathered Time Timestamp grandfatheredTime = Timestamp.valueOf("2000-01-01 00:00:00.0"); return grandfatheredTime; |