List of utility methods to do Timestamp from
Timestamp | convertToTimestamp(Date aJavaDate) convert To Timestamp Timestamp retVal = null; if (aJavaDate != null) { retVal = new Timestamp(aJavaDate.getTime()); return retVal; |
Timestamp | convertToTimestamp(java.util.Date date) Converts java.util.Date to java.sql.Timestamp if (date == null) { throw new IllegalArgumentException("date msut not be null"); Timestamp timestamp = new Timestamp(date.getTime()); return timestamp; |
Timestamp | convertToTimestamp(String dateData) convert To Timestamp try { if (dateData == null) return null; if (dateData.trim().equals("")) return null; int dateObjLength = dateData.length(); String yearString = "2002"; String monthString = "01"; ... |
Timestamp | convertToTimestamp(String dateString, String pattern) convert To Timestamp Date date = convertToDate(dateString, pattern); if (date != null) { return new Timestamp(date.getTime()); } else { return null; |
Timestamp | convertToTimestamp(String s) convert To Timestamp SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS"); Timestamp timestamp = null; try { timestamp = new Timestamp(dateFormat.parse(s).getTime()); } catch (ParseException e) { e.printStackTrace(); return timestamp; ... |
String | convertToTimeStamp(Timestamp timestamp, String format, TimeZone timeZone) This method converts a given time stamp in a specified date format and as per specified time zone String strTimeStamp = ""; if (timestamp == null) return strTimeStamp; final SimpleDateFormat dateFormat = new SimpleDateFormat(format); dateFormat.setTimeZone(timeZone); strTimeStamp = dateFormat.format(timestamp); return strTimeStamp; |
Timestamp | convertToTimestampDate(Date date) convert To Timestamp Date return new Timestamp(date.getTime()); |
Timestamp | convertToTimestampHMS(String dateData) convert To Timestamp HMS if (dateData == null) return null; if (dateData.trim().equals("")) return null; String yearString = dateData.substring(0, 4); String monthString = dateData.substring(4, 6); String dayString = dateData.substring(6, 8); String hourString = dateData.substring(8, 10); ... |
Timestamp | getFirstTimeOfDay(Calendar calendar) get First Time Of Day calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); return new Timestamp(calendar.getTimeInMillis()); |
java.sql.Timestamp | timestampFromCalendar(Calendar calendar) Answer a Timestamp from a Calendar. return timestampFromLong(calendar.getTimeInMillis());
|