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.util.concurrent.TimeUnit ;
  8. import java.time.* ;
  9.  
  10. /* Name of the class has to be "Main" only if the class is public. */
  11. class Ideone
  12. {
  13. public static void main (String[] args) throws java.lang.Exception
  14. {
  15.  
  16. long secondsPerGenericDay = TimeUnit.DAYS.toSeconds( 1 ) ;
  17. long days = Year.of( 2018 ).length() ;
  18. long seconds = ( days * secondsPerGenericDay ) ;
  19.  
  20. // …or…
  21.  
  22. long secondsInYear = TimeUnit.DAYS.toSeconds( Year.of( 2018 ).length() ) ;
  23.  
  24. System.out.println( "seconds: " + seconds + " = secondsInYear: " + secondsInYear ) ;
  25.  
  26.  
  27.  
  28. }
  29. }
Success #stdin #stdout 0.22s 34376KB
stdin
Standard input is empty
stdout
seconds: 31536000 = secondsInYear: 31536000