List of utility methods to do SQL Time
Calendar | mergeDateTime(Date date, Time time) merge Date Time Calendar cal = Calendar.getInstance(); if (date != null) { cal.setTime(date); if (time != null) { Calendar temp = Calendar.getInstance(); temp.setTime(time); cal.set(11, temp.get(11)); ... |
Timestamp | minTime() The value of this constant is equivalent to 0000-00-00 00:00:00.000000000, January 1, 0001. return Timestamp.valueOf(MIN_TIME);
|
Time | minutesToTime(int minutes) minutes To Time int hr = getHours(minutes); int minute = getMinutes(minutes); return hmsToTime(hr, minute, 0); |
Timestamp | parse(String dateTimeString) parse DateTime dateTime = DATE_TIME_FORMATTER.parseDateTime(dateTimeString); return new Timestamp(dateTime.toDateTime().getMillis()); |
Timestamp | parseAMPMFormat(String datetimeString) parse AMPM Format DateFormat dateFormat = new SimpleDateFormat(AM_PM_DATETIME_FORMAT); final Date date = dateFormat.parse(datetimeString); return new Timestamp(date.getTime()); |
Calendar | parseCalendar(final TimeZone timezone, final Locale locale, final String dateformat, final String datestring) Parse a Date string into a Calendar according to the specified Date format, for the specified TimeZone and Locale. final SimpleDateFormat dateFormat; final GregorianCalendar calendar; final java.sql.Date date; dateFormat = new SimpleDateFormat(dateformat, locale); dateFormat.setTimeZone(timezone); date = new java.sql.Date(dateFormat.parse(datestring).getTime()); calendar = new GregorianCalendar(timezone, locale); calendar.setTimeInMillis(date.getTime()); ... |
Timestamp | parseDate(String datetime, String format) Create a Date (time) from a String, returns null on failure Example: Timestamp t = Utils.parseDate("23-06-1975 6:08 AM", "dd-MM-yyyy hh:mm a"); SimpleDateFormat sdf = new SimpleDateFormat(format); Date d = sdf.parse(datetime, new ParsePosition(0)); return new Timestamp(d.getTime()); |
java.sql.Time | readTime(ByteBuffer buffer) read Time move(6, buffer); int hour = read(buffer); int minute = read(buffer); int second = read(buffer); Calendar cal = getLocalCalendar(); cal.set(0, 0, 0, hour, minute, second); return new Time(cal.getTimeInMillis()); |
java.sql.Date | removeTimefromDate(Date inputDate) Method removeTimefromDate. Calendar caldate = Calendar.getInstance(); caldate.setTime(inputDate); int day = caldate.get(Calendar.DATE); int month = caldate.get(Calendar.MONTH); int year = caldate.get(Calendar.YEAR); java.sql.Date sqldate = getSQLDate(year, month, day); return sqldate; |
Time | resetDayTime(Time date) reset Day Time Time result = null; result = (date != null ? new Time(resetDay(date).getTime()) : null); return result; |