fork(2) 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. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13.  
  14. Calendar calBefore = Calendar.getInstance();
  15. calBefore.set(2013, 12, 31);
  16. calBefore.getTime().getTime();
  17.  
  18. Calendar calAfter = Calendar.getInstance();
  19. calAfter.set(2014, 01, 02);
  20. calAfter.getTime().getTime();
  21.  
  22.  
  23. long difference = calAfter.getTime().getTime() - calBefore.getTime().getTime();
  24. System.out.println("日付の差は" + difference / 1000 / 60 / 60 / 24 + "日です。");
  25.  
  26. }
  27. }
Success #stdin #stdout 0.09s 380480KB
stdin
Standard input is empty
stdout
日付の差は2日です。