Solved

Java Date Expiration

Posted on 2011-09-23
3
287 Views
Last Modified: 2012-06-22
Hello,

I was wondering what is the best way to see if a Date is over 24 hours old in Java.  
0
Comment
Question by:cgray1223
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 250 total points
ID: 36590021
Something like
Calendar c = Calendar.getInstance();
c.add(Calendar.DATE, -1);
boolean over24HoursOld = dateBeingTested.before(c.getTime());

Open in new window

0
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 250 total points
ID: 36590035

Date d;


Date d1 = new java.util.Date();

if(d1.getTime()-d.getTime() > 24L*3600L*1000L)System.out.println("it is older");
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 36711820
:)
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
The viewer will learn how to implement Singleton Design Pattern in Java.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now