Solved

Subtracting 1 day from date...

Posted on 2004-04-27
2
331 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
What's wrong with this code? 4 34
jboss 7.1 start up error 1 61
JAVA API design with micro service cloud in mind 1 77
jmss example java 2 32
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

756 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