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.
Joined: Feb 12, 2001
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.