[Logo]
Forums Register Login
dates in java
How to get previous days date in java. i.e. current date-1
Hi
I use the Calendar class as all familiar Date Constructor/methods are deprecated.

This backs up the calendar one day.
The Java 2 API docs are pretty good in showing how to use this class.
Hope this helped.
import java.util.Date;
import java.util.Calendar;
public class Prev
{
public static void main(String args[])
{
Calendar xx = Calendar.getInstance();
Date dt = null;
xx.add(Calendar.DATE,-1);
dt = xx.getTime();
System.out.println("Yesterday Is : " + dt.getDate());
}
}
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards


This thread has been viewed 935 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jun 20, 2018 05:20:56.