Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

adding to java.sql.Date

 
Patrick Mallahan
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create a java.util.GregorianCalendar and use it to perform the arithmetic.
 
Patrick Mallahan
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try new Date(gregorianCalendar.getTimeInMillis())

Padma
 
Raymond Villeno
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this would work too...




Cheers!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic