Jump to content

Calculating the date

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
WingKalimdor

WingKalimdor

    Newbie

  • Members
  • PipPip
  • 13 posts
Hello may I know how to calculate the date in java?
Example we have 06/01/2008 and second date is 08/01/2008

How should I do to (08/01/2008) - (06/01/2008) ??

#2
DivideByZero

DivideByZero

    Learning Programmer

  • Members
  • PipPipPip
  • 35 posts
Date d1 = new Date();
// timed code goes here
Date d2 = new Date();
long elapsed_time = d2.getTime() - d1.getTime();
System.out.println("That took " + elapsed_time + " milliseconds");

SOURCE: java.util.Date