I am using the following code to get today's date.
Calendar cal = Calendar.getInstance();
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
return dateFormat.format(cal.getTime());
But I also want yesteday's date in the same format.
I am using
Calendar cal = Calendar.getInstance();
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
cal.add(Calendar.DATE, -1);
return dateFormat.format(cal.getTime());
but I have a feeling that this will fail once the month or year changes. How do I solve this. Help is very welcome.