How to get previous days date in java. i.e. current date-1
John Bateman
Ranch Hand
Joined: Mar 09, 2000
Posts: 320
posted
0
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.
SOURCE CODE should be SURROUNDED by "code" tags.
Senthil B Kumar
Ranch Hand
Joined: Feb 09, 2004
Posts: 140
posted
0
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()); } }
Work like you don't need the money. Love like you've never been hated. Dance like nobody's watching. Sing like nobody's listening. Live like it's Heaven on Earth.
Currently I Reside HereWEBlog