Solved

Subtracting 1 day from date...

Posted on 2004-04-27
2
326 Views
Last Modified: 2010-03-31
All, I am displaying the current date

new java.text.SimpleDateFormat("yyyy-MM-dd").format (new java.util.Date ());

I want to display current date - 1 and/or +1.

How?
0
Comment
Question by:greedy1
  • 2
2 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 20 total points
ID: 10929291
Calendar cal = Calendar.getInstance();
cal.setTime(yourDate);
cal.add(Calendar.DATE, -1);
String newDate = yourFormat.format(cal.getTime());
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10929932
8-)
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now