Java Utililty Methods Yesterday

List of utility methods to do Yesterday

Description

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

Method

StringgetYesterDay(String pattern)
get Yester Day
SimpleDateFormat simpleFormate = new SimpleDateFormat(pattern);
Calendar ca = Calendar.getInstance();
ca.setTime(new Date());
ca.add(Calendar.DAY_OF_YEAR, -1);
return simpleFormate.format(ca.getTime());
StringgetYesterday6AM()
get Yesterday AM
Calendar today = Calendar.getInstance();
today.add(Calendar.DATE, -1);
today.set(Calendar.HOUR, 6);
today.set(Calendar.AM_PM, Calendar.AM);
today.set(Calendar.MINUTE, 02);
today.set(Calendar.SECOND, 0);
today.set(Calendar.MILLISECOND, 0);
SimpleDateFormat outgoingFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
...
DategetYesterdayBegin()
get Yesterday Begin
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
calendar.add(Calendar.DATE, -1);
return calendar.getTime();
StringgetYesterdayCompactTime()
get Yesterday Compact Time
Calendar cal = Calendar.getInstance();
cal.add(cal.DATE, -1);
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
CurrentTime = formatter.format(cal.getTime());
return CurrentTime;
DategetYesterdayDate(Date date)
get Yesterday Date
date = new Date(-1000L * 60 * 60 * 24 + date.getTime());
return date;
StringgetYesterdayDate(int day)
get Yesterday Date
java.util.Calendar calendar = java.util.Calendar.getInstance();
calendar.add(Calendar.DATE, -(day));
java.util.Date beginDate = calendar.getTime();
SimpleDateFormat dateFmt = new SimpleDateFormat(PATTERN);
String yesterdayDate = dateFmt.format(beginDate);
return yesterdayDate;
StringgetYesterdayDate(String format)
get Yesterday Date
Calendar day = Calendar.getInstance();
day.add(Calendar.DATE, -1);
SimpleDateFormat sdf = new SimpleDateFormat(format);
String date = sdf.format(day.getTime());
return date;
StringgetYesterdayDateAsString()
get the yesterday's date as string using the mysql date format yyyy-MM-dd
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_YEAR, -1);
Date yesterday = calendar.getTime();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(mysqlDateFormat);
return simpleDateFormat.format(yesterday);
StringgetYesterdayFormat(String format)
get Yesterday Format
Date today = new Date(); 
SimpleDateFormat formater; 
formater = new SimpleDateFormat(format);
Calendar cal = Calendar.getInstance();
cal.setTime(today);
cal.add(Calendar.HOUR, -24);
return formater.format(cal.getTime());
StringgetYesterdayFormatString(String format)
get Yesterday Format String
SimpleDateFormat formatter = new SimpleDateFormat(format, Locale.UK);
Date date = new Date();
date.setTime(date.getTime() - (1 * 1000 * 60 * 60 * 24));
return formatter.format(date);