Date Calculations
4 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Mujtaba_Ahmed
Posted On:   Tuesday, September 17, 2002 11:18 AM


If I retreive a date from mySQL table, ResultSet variable myResultSet will have all the field including the date field and I stored it in a string variable. If I want to put that date in another table and add 2 more days to it, how can I do it? Thanks

Re: Date Calculations

Posted By:   Erik_Runia  
Posted On:   Tuesday, September 17, 2002 01:08 PM

i always use the simpledateformat class... seems to work the best for most situations.. give that class a once over.. see what you think.

Re: Date Calculations

Posted By:   Erik_Runia  
Posted On:   Tuesday, September 17, 2002 01:08 PM

i always use the simpledateformat class... seems to work the best for most situations.. give that class a once over.. see what you think.

Re: Date Calculations

Posted By:   Rob_Eamon  
Posted On:   Tuesday, September 17, 2002 12:03 PM

You can use java.text.DateFormat to parse the string to get a java.util.Date object. Use the Date object to create a java.util.Calendar object, which has methods to do calculations such as add two days. Then use DateFormat again to create a string in the desired format for the target table.

Re: Date Calculations

Posted By:   Steven_Martin  
Posted On:   Tuesday, September 17, 2002 11:47 AM

Take it as a date object, convert it to a long variable. Add two days in milliseconds, then get a Date object with using your new long value.



Calendar has some similar functions. I find this manual operation a lot easier.
About | Sitemap | Contact