Re: Subtracting a day from java.sql.Date

Veerendra Jote <[email protected]>
Newsgroups gmane.comp.java.sun.servlet
Message-ID <[email protected]>
Hi Guys,

Hope this is a complete solution.
the output of the program is.

2003-06-21
2003-06-22


&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
import java.sql.Date;
import java.util.Calendar;

public class DateDemo {

        public static void main(String[] args) {
        java.sql.Date d =  new java.sql.Date(103,5,21);
        System.out.println(d);
      // Establish a Calendar object
      Calendar cal = Calendar.getInstance();

      // Set the Calendar object to your date
      cal.setTime(d);

      // Subtracts 5 days from the date
     // cal.add(Calendar.DATE, -5);

      // Increments the date by one
      cal.roll(Calendar.DATE, true);

      // Decrements the date by one
//      cal.roll(Calendar.DATE, false);

      // Convert the Calendar object back to a Date
                Date newDate = new Date(cal.getTime().getTime());

                System.out.println(newDate);



        }
}

___________________________________________________________________________
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.