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

longgetTodayNight()
get Today Night
Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, MY_HOUR_OF_DAY);
cal.set(Calendar.SECOND, MY_SECOND);
cal.set(Calendar.MINUTE, MY_MINUTE);
cal.set(Calendar.MILLISECOND, MY_MILLISECOND);
return cal.getTimeInMillis();
StringgetTodaysDate()
get Todays Date
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("YYYYMMdd-HHmmss");
return sdf.format(date);
StringgetTodaysDate(String dateFormat)
Get today's date and return it in the right format
SimpleDateFormat timeFormat = new SimpleDateFormat(dateFormat);
timeFormat.setTimeZone(TimeZone.getDefault());
return timeFormat.format(new Date());
longgetTodayStart()
get Today Start
Calendar c = new GregorianCalendar();
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
return c.getTime().getTime();
StringgetTodayStr()
get Today Str
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String todayAsString = df.format(new Date());
return todayAsString;
StringgetTodayStr()
getToday get todat string with format YYYY-MM-DD from a Date object
Calendar calendar = Calendar.getInstance();
return getDateStr(calendar.getTime());
StringgetTodayString()
yyyyMMdd
DateFormat dateFormat = createNewDateFormat(shortFormat);
return formatDateString(new Date(), dateFormat);
StringgetTodayString()
get Today String
return format(new Date());
StringgetTodayString()
return a string of todays date suitable for use in a file name
SimpleDateFormat sdf = new SimpleDateFormat("dd_MMM_yyyy"); 
final String dateText = sdf.format(new Date());
return dateText;
StringgetTodayString()
returns Today in String (YYYYMMDD format)
return getTodayInFormat("yyyyMMdd");