Solved

Java Date Expiration

Posted on 2011-09-23
3
296 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
swing controls 2 38
collection output issue 9 94
Eclipse for Java EE development 2 68
Java List 4 76
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
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…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
The viewer will learn how to implement Singleton Design Pattern in Java.

751 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