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

StringgetYestoday(String sourceDate, String format)
get Yestoday
return getFormatDateAdd(getDateFromString(sourceDate, format), -1, format);
BooleanisBeforeToday(Date date)
is Before Today
Long dateTime = date.getTime();
Long startTodayTime = getStartOfToday().getTime();
if (dateTime < startTodayTime) {
    return true;
} else {
    return false;
booleanisBeforeToday(Date date)
is Before Today
return date.compareTo(getToday()) < 0;
booleanisGreaterThanToday(String dateString)
is Greater Than Today
try {
    if (dateString.trim().length() < 12) {
        dateString += " 00:00:00";
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date dueDate = sdf.parse(dateString);
    GregorianCalendar calendar = new GregorianCalendar();
    Date today = calendar.getTime();
...
booleanisToday(Date d1)
test a date represents todays date
return sameDay(d1, new Date());
booleanisToday(Date date)
is Today
Date now = onlyDate(new Date());
Date d = onlyDate(date);
return now.equals(d);
booleanisToday(Date date)
is Today
if (date == null) {
    return false;
String dateAsText = toDateText(date);
String todayAsText = toDateText(now());
return dateAsText.equals(todayAsText);
booleanisToday(Date date, TimeZone timezone)
Returns true if date is today.
Date now = new Date();
SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
if (timezone != null) {
    df.setTimeZone(timezone);
return df.format(now).equals(df.format(date));
booleanisToday(Date dateTime)
is Today
Calendar someCa = GregorianCalendar.getInstance();
someCa.setTime(dateTime);
int syear = someCa.get(Calendar.YEAR);
int smonth = someCa.get(Calendar.MONTH);
int sday = someCa.get(Calendar.DAY_OF_YEAR);
Calendar currentCa = GregorianCalendar.getInstance();
int cyear = currentCa.get(Calendar.YEAR);
int cmonth = currentCa.get(Calendar.MONTH);
...
booleanisToday(final Date date)
is Today
final Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
final int year = calendar.get(YEAR);
final int month = calendar.get(MONTH);
final int day = calendar.get(DAY);
final Calendar today = Calendar.getInstance();
today.setTime(now());
final int tyear = today.get(YEAR);
...