File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes adding to java.sql.Date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "adding to java.sql.Date" Watch "adding to java.sql.Date" New topic
Author

adding to java.sql.Date

Patrick Mallahan
Ranch Hand

Joined: Apr 22, 2005
Posts: 69
How would I go about incrementing days with java.sql.Date? I need to increse an sql.Date by 7 but I dont know how to add to an sql.Date. Can someone help me please?
Christopher Elkins
Ranch Hand

Joined: Oct 26, 2004
Posts: 45
Create a java.util.GregorianCalendar and use it to perform the arithmetic.


Christopher Elkins, SCJP Java 2 Platform
Patrick Mallahan
Ranch Hand

Joined: Apr 22, 2005
Posts: 69
i hoping nobody would say that but oh well, I guess that is the only way. Is that the case?
Christopher Elkins
Ranch Hand

Joined: Oct 26, 2004
Posts: 45
I'm not sure that I understand your aversion to Calendar objects, but yes, that's the only way I can think of to do it. Sorry.
Patrick Mallahan
Ranch Hand

Joined: Apr 22, 2005
Posts: 69
so i understand how to add to a greg cal but how to i convert it back to a sql.Date?
Padma Lalwani
Ranch Hand

Joined: Nov 02, 2004
Posts: 49
Try new Date(gregorianCalendar.getTimeInMillis())

Padma
Raymond Villeno
Ranch Hand

Joined: Jun 21, 2005
Posts: 63
I think this would work too...




Cheers!


"Work Smart Not Hard"
 
 
subject: adding to java.sql.Date