• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Using java.util.Date for comparison

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends

I am stuck in a problem for which i need help from you.

I have written code to convert a date object into a calander object for a functionality in my application.

I am getting the output in the following format after conversion
Thu May 31 00:00:00 IST 2007
Wed Jun 13 00:00:00 IST 2007


Now inside other method i reconvert the calendar object back to Date objects.the code is as below.
Date start=filterStartDate.getTime();
Date end=filterEndDate.getTime();

Now i need to compare the 2 Date objects here and check whether the startdate is less than enddate.
the date objects are again in the same format after conversion
Thu May 31 00:00:00 IST 2007
Wed Jun 13 00:00:00 IST 2007

Can anybody let me know how to do this conversion.If possible provide me piece of code to do it.
waiting for a positive reply from you side.

Regards
Vikeng
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Date class implements the Comparable interface so you can just dowhich will return a value less than zero if start is earlier than end.
[ June 13, 2007: Message edited by: Joanne Neal ]
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you looked at the API documentation of class java.util.Date? It contains methods before() and after() that you can use.
 
All of life is a contant education - Eleanor Roosevelt. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic