Results 1 to 4 of 4

Thread: How to do the Date comparison in Java

  1. #1
    Join Date
    Oct 2008
    Posts
    65

    How to do the Date comparison in Java

    Two projects have come for Bug fixing, the bug fixing was to calculate the date comparison for two consecutive forms, currently it shows only the difference between Two dates, I have search for the solution on the internet but does not found anything relevant to my answer. Any suggestion would be appreciated.

  2. #2
    Join Date
    Jan 2009
    Posts
    150

    Re: How to do the Date comparison in Java

    Create java.util.Date objects based on the dates that you'd like to compare. To make a program on this example firstly we have to make a class ComparingFileDates. Inside the class we have defined three static variables, which will be used for comparing the files. use "public long getTime()" method of each date object to obtain number of milliseconds since January 1, 1970, 00:00:00 GMT for each date, and compare these long values using operators <, >, ==, <>, != as you see fit.

  3. #3
    Join Date
    Feb 2008
    Posts
    180

    Re: How to do the Date comparison in Java

    Inside this method make a two objects of a File class which will take file name as its input in the constructor of File class. Now call the method lastModified by the instances of file classes which will return the time of the file creation. So if you don't like the article then look up the Javadoc API for Calendar.

  4. #4
    Join Date
    Feb 2008
    Posts
    129

    Re: How to do the Date comparison in Java

    The program you will use should have the following classes and methods.
    File: This class extends class Object and implements Comparable and Serializable interface. It takes the file as its input.

Similar Threads

  1. Getting Current Date in Java
    By Level8 in forum Software Development
    Replies: 5
    Last Post: 27-02-2010, 05:26 PM
  2. Exactly match date in java
    By Vodka in forum Software Development
    Replies: 5
    Last Post: 13-02-2010, 02:00 AM
  3. Comparison two Class values in java
    By ISAIAH in forum Software Development
    Replies: 5
    Last Post: 12-02-2010, 05:37 AM
  4. Query with Date in java
    By Gunner 1 in forum Software Development
    Replies: 5
    Last Post: 12-02-2010, 03:55 AM
  5. Comparison between core java and advanced java
    By Prashobh Mallu in forum Software Development
    Replies: 5
    Last Post: 19-01-2010, 10:57 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,015,962.56562 seconds with 16 queries