List of utility methods to do Calendar to Timestamp Convert
Timestamp | Calendar2Timestamp(Calendar c) Calendar Timestamp return new Timestamp(c.getTimeInMillis()); |
String | convertToTimeStamp(Calendar cal) Convert date to short time string return convertToTimeStamp(cal, true);
|
String | convertToTimeStamp(Calendar time, boolean showSeconds) convert To Time Stamp String hours = Integer.toString(time.get(Calendar.HOUR_OF_DAY)); if (hours.length() == 1) { hours = '0' + hours; String minutes = Integer.toString(time.get(Calendar.MINUTE)); if (minutes.length() == 1) { minutes = '0' + minutes; if (showSeconds) { String seconds = Integer.toString(time.get(Calendar.SECOND)); if (seconds.length() == 1) { seconds = '0' + seconds; return hours + ":" + minutes + ":" + seconds; } else { return hours + ":" + minutes; |
Timestamp | nowAsTimestamp() now As Timestamp Calendar objCurrentCalendar = Calendar.getInstance(); return new Timestamp(objCurrentCalendar.getTimeInMillis()); |