Re: Subtracting a day from java.sql.Date

Qingyi Gu <[email protected]>
Newsgroups gmane.comp.java.sun.servlet
Message-ID <[email protected]>
Hope the following approach will help you.

        java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("MMM
dd,yyyy");
        java.sql.Date aDate = new java.sql.Date(System.currentTimeMillis());
        System.out.println(sdf.format(aDate));

--- the output is "May 22,2003"

You can always change the format, such as "MM-dd-yyyy", etc.

Regards,

Qingyi

>From: "Kenny G. Dubuisson, Jr." <[email protected]>
>Reply-To: "A mailing list for discussion about Sun Microsystem's Java
>         Servlet API Technology." <[email protected]>
>To: [email protected]
>Subject: Subtracting a day from java.sql.Date
>Date: Tue, 20 May 2003 14:54:21 -0500
>
>Hello all.  I'm trying to subtract a day from a java.sql.Date class
>variable.  Looking at the java docs, there is no method to do this.  All
>the
>date modification methods belong to another class, java.util.Calendar.  To
>be able subtract a day from my class, should I convert it to the Calendar
>class and then back to the Date class or is there something easier that I'm
>missing.  My main requirement is to have it in a java.sql.Date class when
>done.  Any example code would be much appreciated (I have to admit I'm
>still
>a lightweight in Java).
>
>Thanks,
>Kenny
>
>___________________________________________________________________________
>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
>

_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail

___________________________________________________________________________
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.