Java Utililty Methods Today

List of utility methods to do Today

Description

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

Method

StringformatToDays(Date date)
Formats a Date to the resolution of days:

yyyy-MM-dd

return getFormatToDays().format(date);
StringgetAllToday()
get All Today
Date today = new Date();
return formatAllDate(today);
intgetBetweenTodaysStartDateAndEndDate(Date startDate, Date endDate)
get Between Todays Start Date And End Date
int betweentoday = 0;
if (null == startDate || null == endDate)
    return betweentoday;
if (endDate == null) {
    Calendar calendar = Calendar.getInstance();
    String year = new Integer(calendar.get(1)).toString();
    String month = new Integer(calendar.get(2) + 1).toString();
    String day = new Integer(calendar.get(5)).toString();
...
CalendargetCalendarTodayZero(Calendar today)
Returns the calendar from today with the first hour, minute, second and millisecond.
Calendar calendarZero = new GregorianCalendar(Locale.getDefault());
calendarZero.set(today.get(Calendar.YEAR), today.get(Calendar.MONTH), today.get(Calendar.DATE), 0, 0, 0);
calendarZero.set(Calendar.MILLISECOND, 0);
return calendarZero;
DategetEndOfToday()
get End Of Today
return getEndOfDay(new Date());
DategetFirstDate(Date today)
get First Date
Calendar calendar = Calendar.getInstance();
calendar.setTime(today);
calendar.set(Calendar.DATE, 1);
return calendar.getTime();
CalendargetLastCalendarOfToday()
get Last Calendar Of Today
Calendar startCalendar = getStartCalendarOfToday();
Calendar endCalendar = Calendar.getInstance();
endCalendar.setTime(startCalendar.getTime());
endCalendar.set(Calendar.HOUR_OF_DAY, 23);
endCalendar.set(Calendar.MINUTE, 59);
endCalendar.set(Calendar.SECOND, 59);
return endCalendar;
DategetNDaysFromToday(int n)
get N Days From Today
Calendar cal = Calendar.getInstance(Locale.GERMAN);
cal.add(Calendar.DAY_OF_YEAR, n);
return cal.getTime();
DategetSomedayAfterToday(int x)
get Someday After Today
Calendar c = Calendar.getInstance();
c.set(Calendar.HOUR_OF_DAY, 0);
c.clear(Calendar.MINUTE);
c.clear(Calendar.SECOND);
c.clear(Calendar.MILLISECOND);
c.add(Calendar.DAY_OF_MONTH, x);
return c.getTime();
CalendargetStartOfDayRelative(int daysFromToday)
get Start Of Day Relative
Calendar rtn = getBeginningOfDay();
rtn.add(Calendar.DATE, daysFromToday);
return rtn;