Java Utililty Methods SQL Date Create

List of utility methods to do SQL Date Create

Description

The list of methods to do SQL Date Create are organized into topic(s).

Method

DategetDayByWeekString(Date date, String weekString)
get Day By Week String
return getDayByWeekString(date, weekString, false);
longgetDays(Date from, Date to)
get Days
long s = from.getTime();
long e = to.getTime();
return Math.round(((e - s) / (24 * 60 * 60 * 1000.0)));
DategetDaysLater(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.TimestampgetDayStart(Date stamp)
get Day Start
return getDayStart(stamp, 0);
StringgetLastDateOfQuarter()
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));
DategetLastDay(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;
intgetLastDay(Date dt)
get Last Day
Calendar cal = Calendar.getInstance();
cal.setTime(dt);
int lastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
return lastDay;
intgetLastDay(java.util.Date dt)
get Last Day
return getLastDay(convertFormat(dt, "yyyyMM"));
DategetLastDayofMonth(Date date1)
get Last Dayof Month
Calendar cld = Calendar.getInstance();
cld.setTime(date1);
cld.set(5, 1);
return cld.getTime();
java.sql.DategetLastDayOfMonth(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());
...