File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Yesterdays Date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Yesterdays Date" Watch "Yesterdays Date" New topic

Yesterdays Date

Mary Cole
Ranch Hand

Joined: Dec 02, 2000
Posts: 362
Hi All,

How do i get yesterdays date and date 30 days bk...
its urgent...
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

First EaseUp.

Have a look at java.util.GregorianCalendar. In particular, the getInstance() and add(int field, int amount) methods. You should be able to work it out from that.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
And, just in case it happens, don't think you're the first person who stared at the API half a day before realizing the amount could be negative.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I agree. Here's the link:
subject: Yesterdays Date
It's not a secret anymore!