Solved

Java Date Expiration

Posted on 2011-09-23
3
291 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
split53 challenge 7 97
HSSFWorkbook cannot be resolved error 10 71
even odd program using while loop 3 41
Convert from a json string array to a Java object 3 34
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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 …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

803 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