Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Java: compute the difference between two dates

Java: compute the difference between two dates
{filelink=754}

import java.util.*;
public class DifferenceDate
{
        public static void main(String[] av) {
                Date date1 = new GregorianCalendar(2011,11,31,23,59).getTime( );
                Date today = new Date( );
                // Compute difference
                long diff = today.getTime( ) - date1.getTime( );
                System.out.println("Difference  between "+date1+ " and " + today +
                        " is" + (diff / (1000*60*60*24)) + " day(s).");
        }
}

No comments yet.

Leave a Comment