This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

adding to java.sql.Date  RSS feed

 
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
Boost this thread!