How to get the current timestamp In Java

290 Flares Twitter 0 Facebook 0 Google+ 290 LinkedIn 0 Filament.io 290 Flares ×

Getting the current timestamp in java  is straightforward. Here is how you can get this

Another problem usually people ask is how to find the elapsed time between two timestamps or date. This is also very easy to find in java. The steps are as follows

  1. find the current time in milliseconds
  2. find the millisecond equivalent from the timestamp you want to compare
  3. calculate the difference

Here is an example to illustrate this