Forums Register Login

java date

+Pie Number of slices to send: Send
i want to subtract date of previous month which is store in
database from current date to get days because i want that if any record in data base after 15 days from the date when it is inserted should be deleted .we know that date is returned in a string.so we can not subtract it.if we can take differen dd mm yy in ineger through create object of Calendar class.then when we subtract dd mm yy
3 4 2001
29 3 2001

And after all when we get dd mm yy these three integers how to store it and how to insert it to database.
after that when we get current date which is store in string varible then how to subtract this previous date from current date which is stored in a string varible.
+Pie Number of slices to send: Send
Hi Pawan !
Have a look into java.util.Calender and GregorianCalender class. There you can find how to set the calender to a particular date and how to get the date in milliseconds (long).
Get the current date in Milliseconds which is a long (currentlong) .
Get the data-base date in Milliseconds say (databaselong).
differencelong = currentlong - databaselong;
1 Day = 86400 seconds
1 second = 1000 milliseconds
onedaylong = 86400 X 1000;

So divide your result differencelong with onedaylong to get number of days betwen them.
Hope this will help.
Dinner will be steamed monkey heads with a side of tiny ads.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1252 times.
Similar Threads
how to change the date,Time format after accessing it from the database
date validation
I need a date... No, really!
Need your help in DATE
data handling
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 07:34:11.