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

DategetFirstDayOfQuarter(Date date)
get First Day Of Quarter
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return getFirstDayOfQuarter(calendar.get(Calendar.YEAR), getQuarterOfYear(date));
DategetFirstOfDay(Date date)
get First Of Day
String dateString = new SimpleDateFormat(EARER_IN_THE_DAY).format(date);
try {
    return new SimpleDateFormat(LONG_DATE_FORMAT_STR).parse(dateString);
} catch (ParseException e) {
    return null;
DategetFirstTimeInDay(Date day)
get First Time In Day
Calendar date = Calendar.getInstance();
date.setTime(day);
date.set(Calendar.HOUR_OF_DAY, 0);
date.set(Calendar.MINUTE, 0);
date.set(Calendar.SECOND, 0);
date.set(Calendar.MILLISECOND, 0);
return date.getTime();
StringgetFormattedNowDatePlusDays(int days, String dateFormat)
get Formatted Now Date Plus Days
Date nowDate = getNowDate();
Date futureDate = addDaysToDate(nowDate, days);
return dateToString(futureDate, dateFormat);
intgetFullAge(Date birthday)
get Full Age
if (birthday == null) {
    return 0;
DateFormat df = new SimpleDateFormat("yyyyMMdd");
int start = Integer.parseInt(df.format(birthday));
int end = Integer.parseInt(df.format(new Date()));
int fullAge = (end - start) / 10000;
return fullAge;
...
DategetIncrementDaysSecond(String strDate, int sec)
get Increment Days Second
SimpleDateFormat sdf = null;
Calendar calendar = new GregorianCalendar();
Date date = null;
int year = 0;
int month = 0;
int day = 0;
int hour = 0;
int minute = 0;
...
StringgetInsertDayDate(int days)
get Insert Day Date
Calendar day = Calendar.getInstance();
day.add(Calendar.DATE, -days);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
return simpleDateFormat.format(day.getTime());
StringgetIntervalDate(String date, int intervalDays)
get Interval Date
Calendar cal = Calendar.getInstance();
int year = Integer.parseInt(String.valueOf(date).substring(0, 4));
int month = Integer.parseInt(String.valueOf(date).substring(4, 6));
int day = Integer.parseInt(String.valueOf(date).substring(6, 8));
cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH, month - 1);
cal.set(Calendar.DAY_OF_MONTH, day);
cal.add(Calendar.DATE, intervalDays);
...
intgetIntervalDays(Date fDate, Date oDate)
get Interval Days
String fDate1 = toString(fDate, "yyyyMMdd");
String oDate1 = toString(oDate, "yyyyMMdd");
java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("yyyyMMdd");
java.util.Date cDate = df.parse(fDate1);
java.util.Date dDate = df.parse(oDate1);
return (int) ((cDate.getTime() - dDate.getTime()) / (24 * 60 * 60 * 1000));
longgetIntevalDays(String startDate, String endDate)
get Inteval Days
try {
    return getIntevalDays(parse(startDate, YYYY_MM_DD), parse(endDate, YYYY_MM_DD));
} catch (Exception ee) {
    return 0l;