aspose file tools*
The moose likes Beginning Java and the fly likes dates in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "dates in java" Watch "dates in java" New topic
Author

dates in java

Dinesh Bhogle
Greenhorn

Joined: Mar 12, 2001
Posts: 6
How to get previous days date in java. i.e. current date-1
John Bateman
Ranch Hand

Joined: Mar 09, 2000
Posts: 320
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
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 Here WEBlog
 
 
subject: dates in java