Java Utililty Methods Day of

List of utility methods to do Day of

Description

The list of methods to do Day of are organized into topic(s).

Method

intgetDefaultOffsetDays(String strDate)
get Default Offset Days
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date param_date = fmt.parse(strDate);
return getOffsetDays(param_date, new Date());
StringgetDeltaDay(String day, int delta)
get Delta Day
GregorianCalendar rightNow = new GregorianCalendar(Integer.parseInt(day.substring(0, 4)),
        Integer.parseInt(day.substring(4, 6)) - 1, Integer.parseInt(day.substring(6, 8)));
rightNow.add(Calendar.DAY_OF_YEAR, delta);
return getDefaultDateFormat().format(rightNow.getTime());
longgetDeltaDays(String date)
get Delta Days
long deltaDays = 0;
try {
    Date d = sdf.parse(date);
    deltaDays = (d.getTime() - getCurrentTime()) / MILLI_SEC_PER_DAY;
} catch (Throwable t) {
    System.out.println(" [Error] Problem parsing date: " + date + ", Exception: " + t.getMessage());
return deltaDays;
...
StringgetDeltaNow(int deltaDays)
get Delta Now
Calendar c = Calendar.getInstance();
c.add(Calendar.DAY_OF_MONTH, deltaDays);
return new SimpleDateFormat(YYYYMMDDHHMMSS_FORMAT).format(c.getTime());
StringgetDisplayDate(final Date date, final int offsetDays)
get Display Date
String val = null;
if (date != null) {
    Date offsetDate = date;
    if (offsetDays > 0) {
        offsetDate = getDateAfter(date, offsetDays);
    val = DISPLAY_FORMAT.format(offsetDate);
return val;
StringgetEndDayofMouth(String date, String inPattern, String outPattern)
get End Dayof Mouth
SimpleDateFormat sdf = new SimpleDateFormat(inPattern);
String __return = "";
try {
    Date d = sdf.parse(date);
    Calendar c = Calendar.getInstance();
    c.setTime(d);
    int start = c.getActualMaximum(Calendar.DAY_OF_MONTH);
    c.set(Calendar.DAY_OF_MONTH, start);
...
StringgetFirstDay(boolean isNeedHH24MISS)
get First Day
SimpleDateFormat df = new SimpleDateFormat(YYYY_MM_DD);
Calendar calendar = Calendar.getInstance();
Date theDate = calendar.getTime();
GregorianCalendar gcLast = (GregorianCalendar) Calendar.getInstance();
gcLast.setTime(theDate);
gcLast.set(Calendar.DAY_OF_MONTH, 1);
String day_first = df.format(gcLast.getTime());
StringBuffer str = new StringBuffer().append(day_first);
...
StringgetFirstDay(boolean withTime)
get First Day
String formatStr = "yyyy-MM-dd";
if (withTime) {
    formatStr += " HH:mm:ss";
Calendar cal = Calendar.getInstance();
SimpleDateFormat datef = new SimpleDateFormat(formatStr);
cal.set(GregorianCalendar.DAY_OF_MONTH, 1);
Date beginTime = cal.getTime();
...
DategetFirstDay(Date date)
get First Day
Calendar c = Calendar.getInstance();
c.setTime(date);
c.set(Calendar.DAY_OF_MONTH, 1);
return c.getTime();
StringgetFirstDayInThisQuarter(String nowDate)
get First Day In This Quarter
String ntime = "";
int nowMonth;
int nowYear;
try {
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
    Date startDate = df.parse(nowDate);
    nowMonth = startDate.getMonth() + 1;
    nowYear = startDate.getYear() + 1900;
...