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

StringgetSpecifiedDayAfter(String specifiedDay)
get Specified Day After
Calendar c = Calendar.getInstance();
Date date = null;
date = new SimpleDateFormat("yy-MM-dd").parse(specifiedDay);
c.setTime(date);
int day = c.get(Calendar.DATE);
c.set(Calendar.DATE, day + 1);
String dayAfter = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
return dayAfter;
...
DategetSpecifiedDayAfter(String specifiedDay, int afterDay)
get Specified Day After
Calendar c = Calendar.getInstance();
Date date = null;
try {
    date = new SimpleDateFormat("yyyy-MM-dd").parse(specifiedDay);
} catch (ParseException e) {
    e.printStackTrace();
c.setTime(date);
...
DategetSpecifiedDayTimeAfter(Date date)
get Specified Day Time After
Calendar c = Calendar.getInstance();
c.setTime(date);
int day = c.get(Calendar.DATE);
c.set(Calendar.DATE, day + 1);
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
return c.getTime();
...
StringgetStandardDayFormat(Date day)
get Standard Day Format
return gStandardDayFormat.format(day);
StringgetStartDate(int days, String strEndDate)
get Start Date
Calendar endCal = Calendar.getInstance();
Date endDate = stringToDate(strEndDate, STRING_DATE_FORMAT);
endCal.setTime(endDate);
endCal.add(Calendar.DATE, -days);
SimpleDateFormat sdf = new SimpleDateFormat(STRING_DATE_FORMAT);
return sdf.format(endCal.getTime());
DategetStartDateByDays(Date endDate, int days)
get Start Date By Days
Calendar calendarEndDate = Calendar.getInstance();
calendarEndDate.setTime(endDate);
calendarEndDate.add(Calendar.DAY_OF_YEAR, 0 - days);
return calendarEndDate.getTime();
StringgetStringAfterNDay(String str, int n)
get String After N Day
Calendar ca = parseStringToCalendar(str);
if (ca == null) {
    return null;
ca.add(Calendar.DATE, n);
String strDate = ca.get(Calendar.YEAR) + "-";
int intMonth = ca.get(Calendar.MONTH) + 1;
if (intMonth < 10) {
...
StringgetStringDay(Calendar cal)
get String Day
return new SimpleDateFormat("dd").format(cal.getTime());
StringgetTargetDay(String day, int beforeOrAfterDays)
get Target Day
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
Date date = null;
Date targetDate = null;
try {
    date = sdf.parse(day);
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);
    cal.add(Calendar.DATE, beforeOrAfterDays);
...
DategetTheDayBefore(Date date)
get The Day Before
return new Date(date.getTime() - (long) 24 * (long) 60 * 60 * 1000);