Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
Ron McLeod
paul wheaton
Jeanne Boyarsky
Sheriffs:
Paul Clapham
Devaka Cooray
Saloon Keepers:
Tim Holloway
Roland Mueller
Himai Minh
Bartenders:
Forum:
Beginning Java
adding to java.sql.Date
Patrick Mallahan
Ranch Hand
Posts: 69
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
Posts: 45
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Create a
java.util.GregorianCalendar
and use it to perform the arithmetic.
Patrick Mallahan
Ranch Hand
Posts: 69
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
i hoping nobody would say that
but oh well, I guess that is the only way. Is that the case?
Christopher Elkins
Ranch Hand
Posts: 45
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
Posts: 69
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
Posts: 49
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Try new Date(gregorianCalendar.getTimeInMillis())
Padma
Raymond Villeno
Ranch Hand
Posts: 63
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I think this would work too...
Calendar cNow = Calendar.getInstance(); Date dNow = cNow.getTime(); cNow.add(Calendar.DATE, 7); Date dSeven = cNow.getTime(); SimpleDateFormat format = new SimpleDateFormat("MMM dd, yyyy hh:mm:ss a"); String dateNow = format.format(dNow); String dayBefore = format.format(dSeven); System.out.println(dateNow); System.out.println(daySeven); //here is your current day + 7 Date date = new Date(); System.out.println(date);
Cheers!
"Work Smart Not Hard"
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Converting String to util.Date and then sql.Date
sql.date trouble
Use of sql.Date
util.Date to sql.Date
util.Date to sql.Date
More...