Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 208
  • Last Modified:

Compare two date / times...

I want to evaluate whether date/time a > date/time b.

For example, I pass in 2004-09-15-13.00.00(variable a), if that is greater than (Later than) 2004-09-15-08.00.00(variable b) then I need to flag it as "late".

The dates could be different days as well....not just times.
0
greedy1
Asked:
greedy1
  • 4
  • 3
2 Solutions
 
CEHJCommented:
boolean late = date1.after(date2);
0
 
CEHJCommented:
If you've got them as Strings, use SimpleDateFormat, like i showed you in your last question
0
 
zzynxSoftware engineerCommented:
if a and b are Date's:

boolean late = a.after(b);
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
zzynxSoftware engineerCommented:
>> If you've got them as Strings, use SimpleDateFormat
indeed :)
0
 
zzynxSoftware engineerCommented:
Like

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-hh.mm.ss");
Date a, b;
try {
        a = sdf.parse(yourString1);
        b = sdf.parse(yourString2);
} catch (ParseException ex) {
}
0
 
greedy1Author Commented:
You guys have officially made me LAZY.  I briefly scanned Date javadoc, skipped over 'after()' obviously and thought I'll just go ask on EE it's easier than looking....LAZY : )

CEHJ beat you to it zzynx, but thanks for the effort , I'll increase the points and give you some too.
0
 
CEHJCommented:
8-)
0
 
zzynxSoftware engineerCommented:
>> You guys have officially made me LAZY
:°D

>> CEHJ beat you to it zzynx,
Yeah, with one minute. The guy's like lightening ;°)

>> but thanks for the effort , I'll increase the points and give you some too.
much appreciated, mate. Thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now