List of utility methods to do SQL Date Create
Date | getDayByWeekString(Date date, String weekString) get Day By Week String return getDayByWeekString(date, weekString, false);
|
long | getDays(Date from, Date to) get Days long s = from.getTime(); long e = to.getTime(); return Math.round(((e - s) / (24 * 60 * 60 * 1000.0))); |
Date | getDaysLater(Date date, int days) get Days Later Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.add(Calendar.DAY_OF_MONTH, days); Date date2 = new Date(calendar.getTimeInMillis()); return date2; |
java.sql.Timestamp | getDayStart(Date stamp) get Day Start return getDayStart(stamp, 0);
|
String | getLastDateOfQuarter() get Last Date Of Quarter Calendar calendar = Calendar.getInstance(); int year = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH) + 1; int quater = (month + 2) / 3; SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); return formatter.format(getLastDateOfQuarter(year, quater)); |
Date | getLastDay(Date date) get Last Day Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.add(Calendar.MONTH, 1); calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.add(Calendar.DAY_OF_MONTH, -1); Date date2 = new Date(calendar.getTimeInMillis()); return date2; |
int | getLastDay(Date dt) get Last Day Calendar cal = Calendar.getInstance(); cal.setTime(dt); int lastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH); return lastDay; |
int | getLastDay(java.util.Date dt) get Last Day return getLastDay(convertFormat(dt, "yyyyMM")); |
Date | getLastDayofMonth(Date date1) get Last Dayof Month Calendar cld = Calendar.getInstance();
cld.setTime(date1);
cld.set(5, 1);
return cld.getTime();
|
java.sql.Date | getLastDayOfMonth(java.sql.Date date) get Last Day Of Month Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
int maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
calendar.set(Calendar.DAY_OF_MONTH, maxDay);
calendar.set(Calendar.HOUR_OF_DAY, 23);
calendar.set(Calendar.MINUTE, 59);
calendar.set(Calendar.SECOND, 59);
date.setTime(calendar.getTimeInMillis());
...
|