List of utility methods to do Yesterday
Date | yesterday() yesterday return startOfDay(addDays(getCurrentDate(), -1));
|
Date | yesterday(Date date) yesterday Date newDate = (Date) date.clone(); long time = newDate.getTime() / 1000L - 86400L; newDate.setTime(time * 1000L); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); try { newDate = format.parse(format.format(newDate)); } catch (Exception ex) { System.out.println(ex.getMessage()); ... |
String | yesterday(int daybefore, String pattern) yesterday Calendar cal = yesterday(daybefore); return new SimpleDateFormat(pattern).format(cal.getTime()); |
Date | yesterdayDate() yesterday Date SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar c = Calendar.getInstance(); c.add(Calendar.DATE, -1); return StringToDate(sdf.format(c.getTime())); |
String | yesterdayDate3() yesterday Date Calendar cal = Calendar.getInstance(); cal.setTime(new Date()); cal.set(Calendar.HOUR, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.DATE, cal.get(Calendar.DATE) - 1); return convertDate2String4(cal.getTime()); |