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. import java.time.* ;
  8.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class Ideone
  11. {
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14. // Using terrible old legacy class `Date`.
  15. Date x = new Date( System.currentTimeMillis() ) ;
  16. System.out.println( x ) ;
  17.  
  18. boolean iJavaUtilsDate = x instanceof java.util.Date ;
  19. System.out.println( "instanceof java.util.Date: " + iJavaUtilsDate ) ;
  20.  
  21. // Using modern *java.time* class `Instant`.
  22. Instant y = Instant.now() ; // Capture the current moment in UTC.
  23. System.out.println( y ) ;
  24.  
  25.  
  26. }
  27. }
Success #stdin #stdout 0.25s 35744KB
stdin
Standard input is empty
stdout
Tue Jul 31 04:30:08 GMT 2018
instanceof java.util.Date: true
2018-07-31T04:30:08.603Z