• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Thread or not

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I'm writing an application that lists tasks for users. These tasks have a follow up date of 24 hours. What would be the best way to check whether the time for following up on a task has expired?
Tys
 
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you have a timestamp?
If so, finding the expiration date should be trivial.
The millisecond formula for a day is - 1000 * 60 * 60 * 24
I use this for a lot of date calculation.
Get the date in milliseconds. This can be done with a regular java.util.Date() class. Figuring out how to convert your timestamp to a Date class is up to you since I don't have more to go on here. The actual method call is getTime().
Once you have the time in milliseconds, add the value of the above formula. That's your expiration date.
Now get the current time in milliseconds. This is as trivial as declaring a new Date() object and calling getTime(). Compare the values. If the current time is greater than the timestamp + 24 hours, then your task is over the limit.
 
I miss the old days when I would think up a sinister scheme for world domination and you would show a little emotional support. So just look at this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic