List of utility methods to do SQL Time From
Date | getDateTime(ResultSet rs, String field, Calendar cal) get Date Time Date date = rs.getDate(field, cal); Date time = rs.getTime(field, cal); if (date == null || time == null) { return null; } else { cal.clear(); cal.set(1900 + date.getYear(), date.getMonth(), date.getDate(), time.getHours(), time.getMinutes(), time.getSeconds()); ... |
java.util.Date | getDateTime(String dateTime) get Date Time java.util.Date strDate = java.sql.Date.valueOf(dateTime);
return strDate;
|
java.sql.Date | getDateTime(String s) Gets the date and time from the YYYY-MM-DD HH:MM:SS format. if (s.length() != 19) throw new IllegalArgumentException("Invalid date: " + s); Calendar cal = Calendar.getInstance(); int year = Integer.parseInt(s.substring(0, 4)); cal.set(Calendar.YEAR, year); int month = Integer.parseInt(s.substring(5, 7)); if (month < 1 || month > 12) throw new IllegalArgumentException("Invalid date: " + s); ... |
Date | getDatetime(String value) Helper to create a date-time given a string of the form yyyy-mm-dd hh:mm:ss. return value != null ? new Date(Timestamp.valueOf(value).getTime()) : null; |
String | getDateTimeBySecond(long timeMillis) get Date Time By Second Timestamp timestamp = new Timestamp(timeMillis); return timestamp.toString(); |
String | getDateTimeFormat() get Date Time Format return DATE_TIME_FORMAT;
|
Timestamp | getDateTimeRtnTime(Date date, String time) get Date Time Rtn Time SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Timestamp timeStamp = null; sdf.setLenient(false); try { String dateStr = sdf.format(date); timeStamp = Timestamp.valueOf(dateStr + " " + time); } catch (Exception e) { return timeStamp; |
String | getDateTimeStr(Date date) getDateStr get a string with format YYYY-MM-DD HH:mm:ss from a Date object if (date != null) { return FORMAT_YYYY_MM_DD_HMS.format(date); } else return ""; |
String | getDateTimeString(java.sql.Date dd) get Date Time String if (dd == null) { return ""; String tds = dd.toString(); java.sql.Time tt = new java.sql.Time(dd.getTime()); tds += (" " + tt.toString()); return tds; |
String | getDateTimeString(String format) get Date Time String return toDateTimeString(new java.util.Date(), format); |