List of utility methods to do Yesterday
String | getYesterDay(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()); |
String | getYesterday6AM() 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"); ... |
Date | getYesterdayBegin() 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();
|
String | getYesterdayCompactTime() 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; |
Date | getYesterdayDate(Date date) get Yesterday Date date = new Date(-1000L * 60 * 60 * 24 + date.getTime()); return date; |
String | getYesterdayDate(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; |
String | getYesterdayDate(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; |
String | getYesterdayDateAsString() 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); |
String | getYesterdayFormat(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()); |
String | getYesterdayFormatString(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); |