I have wrote a method to get the current date in the format of yyyy-MM-dd
and want to be able to also create another method for getting yesterday's date, the day before the current date. All this needs is the date and not the timestamp. I am not trying to use Calendar
as well. I have set up the current date this way:
public class DateWithNoTimestamp
{
private static final String CURRENT_DATE_FORMAT = "yyyy-MM-dd";
public final static String getCurrentDate()
{
DateFormat dateFormat = new SimpleDateFormat(CURRENT_DATE_FORMAT);
Date date = new Date();
return dateFormat.format(date);
}
}
This works to get the current date, now the separate method getYesertdayDate()
I'm having trouble with. How can I set it up in a similar way as I did with getCurrentDate()
while subtracting one day ?
Calendar
. – Labarbera