List of utility methods to do Timestamp Field
java.sql.Timestamp | getDayEnd(java.sql.Timestamp stamp, int daysLater) get Day End Calendar tempCal = Calendar.getInstance(); tempCal.setTime(new java.util.Date(stamp.getTime())); tempCal.set(tempCal.get(Calendar.YEAR), tempCal.get(Calendar.MONTH), tempCal.get(Calendar.DAY_OF_MONTH), 23, 59, 59); tempCal.add(Calendar.DAY_OF_MONTH, daysLater); return new java.sql.Timestamp(tempCal.getTime().getTime()); |
int | getDayOfMonthBy(Timestamp ts) get Day Of Month By Calendar calendar = getCalendar(); if (ts != null) calendar.setTimeInMillis(ts.getTime()); return calendar.get(Calendar.DAY_OF_MONTH); |
int | getDayOfTime(Timestamp timestamp) get Day Of Time Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(timestamp.getTime());
return calendar.get(Calendar.DAY_OF_MONTH);
|
int | getDayOfWeek(Timestamp timestamp) get Day Of Week Calendar cal = Calendar.getInstance(); Date date = new Date(timestamp.getTime()); cal.setTime(date); int dayForWeek = 0; dayForWeek = cal.get(Calendar.DAY_OF_WEEK); if (dayForWeek == 1) { dayForWeek = 7; } else { ... |
int | getDaysBetween(Timestamp start, Timestamp end) Calculate the number of days between start and end. boolean negative = false; if (end.before(start)) { negative = true; Timestamp temp = start; start = end; end = temp; GregorianCalendar cal = new GregorianCalendar(); ... |
long | getDayStartTimestamp() get Day Start Timestamp Timestamp[] timestamps = getDayStartEnd(); return Long.valueOf(dateToStamp(timestamps[0] + "")); |
Timestamp | getDayTime(Timestamp day, Timestamp time) Return the day and time GregorianCalendar cal_1 = new GregorianCalendar(); cal_1.setTimeInMillis(day.getTime()); GregorianCalendar cal_2 = new GregorianCalendar(); cal_2.setTimeInMillis(time.getTime()); GregorianCalendar cal = new GregorianCalendar(); cal.set(cal_1.get(Calendar.YEAR), cal_1.get(Calendar.MONTH), cal_1.get(Calendar.DAY_OF_MONTH), cal_2.get(Calendar.HOUR_OF_DAY), cal_2.get(Calendar.MINUTE), cal_2.get(Calendar.SECOND)); cal.set(Calendar.MILLISECOND, 0); ... |
Timestamp | getDefaultTimestamp() Creates a default timestamp. return new Timestamp(new Date().getTime()); |
int | getDiffDay(Timestamp time1, Timestamp time2) get Diff Day return getDay1(new Date(time2.getTime()), new Date(time1.getTime())); |
double | getDifferenceInHours(Timestamp startDateTime, Timestamp endDateTime) get Difference In Hours int difference = 0;
Calendar startCalendar = Calendar.getInstance();
startCalendar.setTime(startDateTime);
Calendar endCalendar = Calendar.getInstance();
endCalendar.setTime(endDateTime);
Calendar startCompare = Calendar.getInstance();
startCompare.setTime(startDateTime);
startCompare.set(Calendar.HOUR_OF_DAY, 0);
...
|