fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. import java.sql.Timestamp;
  9. import java.util.Date;
  10.  
  11. class CompareTimestamps {
  12. public static void main(String[] args) {
  13.  
  14. Timestamp timestamp1 = new Timestamp(new Date().getTime());
  15. System.out.println("t1 " + timestamp1);
  16.  
  17. Timestamp timestamp2 = null;
  18. System.out.println("t2 " + timestamp2);
  19.  
  20.  
  21. timestamp2 = timestamp1;
  22. System.out.println("Checking the timestamp2 " + timestamp2);
  23.  
  24. //timestamp1 = new Timestamp(new Date().getTime());
  25.  
  26. //timestamp2 = new Timestamp(timestamp1.getTime());
  27.  
  28. }
  29. }
Success #stdin #stdout 0.05s 2184192KB
stdin
Standard input is empty
stdout
t1 2019-07-18 05:51:43.713
t2 null
Checking the timestamp2 2019-07-18 05:51:43.713