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

booleanafterToday(String date)
after Today
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
String today = format.format(new Date());
if (date.compareTo(today) >= 0) {
    format = null;
    return true;
format = null;
return false;
...
DatebeforeToday(int days)
before Today
GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(todayMiddleNight());
calendar.add(Calendar.DATE, -days);
return calendar.getTime();
long[]converTimeToDayStartEnd(long time, long[] out)
convert a time to the corresponding time of the start and end of the day it exists on.
Calendar cal = new GregorianCalendar();
Calendar calEnd = new GregorianCalendar();
cal.setTime(new Date(time));
cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
calEnd.setTime(cal.getTime());
calEnd.add(Calendar.DATE, 1); 
if (out == null) {
    return new long[] { cal.getTimeInMillis(), calEnd.getTimeInMillis() };
...
FilecreateTodayDirectory(File destDir)
Create a subDirectory having the actual date as name, within a specified destination directory.
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy_MM_dd");
final String newPath = (new StringBuffer(destDir.getAbsolutePath().trim()).append(File.separatorChar)
        .append(sdf.format(new Date()))).toString();
File dir = new File(newPath);
if (!dir.exists())
    dir.mkdir();
return dir;
FilecreateTodayDirectory(File destDir, String inputFileName)
Creates the today directory.
return createTodayDirectory(destDir, inputFileName, false);
FilecreateTodayPrefixedDirectory(final String prefix, final File parent)
Creates the today prefixed directory.
final SimpleDateFormat SDF_HMS = new SimpleDateFormat("yyyy_MM_dd_hhmmsss");
final String newPath = (new StringBuffer(parent.getAbsolutePath().trim()).append(File.separatorChar)
        .append(prefix).append(File.separatorChar).append(SDF_HMS.format(new Date()))).toString();
File dir = new File(newPath);
if (!dir.exists()) {
    dir.mkdirs();
return dir;
...
booleandeletePreviousDay(Calendar today, String temppath)
Deletes any files downloaded from the previous day
Calendar yesterday = (Calendar) today.clone();
yesterday.add(Calendar.DATE, -2);
File to_delete = new File(temppath + calendarToString(yesterday));
return to_delete.delete();
DateendOfToday()
end Of Today
return endOfDay(new Date());
StringformatToday()
format Today
return format(new Date());
StringformatToday()
format Today
return formatDate("MM.dd.yy", 0, 0, 0);