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

StringtodayAsSimpleIsoDate(Date date)
Today as simple iso date.
Format formatter = new SimpleDateFormat("yyyyMMdd");
return formatter.format(date);
StringtodayAsXSDDateString()
today As XSD Date String
return calendarToXSDDateString(new GregorianCalendar());
DatetodayAtDayEnd()
today At Day End
final Calendar cal = Calendar.getInstance();
cal.setTime(new Date(System.currentTimeMillis()));
adjustToDayEnd(cal);
return cal.getTime();
StringtodayDate()
today Date
Calendar now = Calendar.getInstance();
now.setTime(new java.util.Date());
return String.valueOf(now.get(Calendar.DAY_OF_MONTH)) + "-" + String.valueOf(now.get(Calendar.MONTH) + 1)
        + "-" + String.valueOf(now.get(Calendar.YEAR));
inttodayMinute()
today Minute
Calendar c = Calendar.getInstance();
int hh = c.get(Calendar.HOUR_OF_DAY);
int mm = c.get(Calendar.MINUTE);
return hh * 60 + mm;
DatetodayPlusDays(int days)
today Plus Days
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.add(Calendar.DATE, days);
return calendar.getTime();
DatetoDaysBeforeOrAfter(Date date, Integer days)
to Days Before Or After
return add(date, Calendar.DAY_OF_YEAR, days);
StringtodaysDate(int style)
Get today's date in various formats style=0 -> ddMMyyyy style=1 -> YYYY-MM-dd style=2 -> dd-MMM-YYY
Date date = new Date();
SimpleDateFormat formatterOut = null;
if (style == 0) {
    formatterOut = new SimpleDateFormat("ddMMMyyyy");
} else if (style == 1) {
    formatterOut = new SimpleDateFormat("yyyy-MM-dd");
} else if (style == 2) {
    formatterOut = new SimpleDateFormat("dd-MMM-yyyy");
...
StringtodaySortedTimestamp()
today Sorted Timestamp
return sortedTimestampFormat(today());
DatetodayStart()
today Start
return getDateWithoutTimePart(new Date());