Forums Register Login

delete logfiles that are older than 3 months

+Pie Number of slices to send: Send
hi all
how can i check if i file is older than 3 months? i have to dates:
-the date when the logfile was created
- the current date
thanks
angela
+Pie Number of slices to send: Send
The lastModified() of File will return a long representing the date last modified. Convert that to a Date and do your check.
+Pie Number of slices to send: Send
To expand a little on the previous post, first set up a constant that would hold the number of miliseconds in the three month period--approximately 90 days. Subtract this number from the current day's date which can be found using System.currentTimeMillis(). If the date of the file( from the lastModified() method of File) is less than the number just calculated above, then delete it; else keep it.
Hope this helps.
-Jason
Nothing? Or something? Like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 863 times.
Similar Threads
Compare date cannot be greater than 12 months apart
Dirty math problem
When did you first feel 'old' (assuming you do)
O-Yes
How to copy old data from one table to another in same database
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 17:25:06.