fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.time.* ;
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. LocalDate today = LocalDate.now ( ZoneId.of ( "America/Edmonton" ) ) ;
  14. LocalDate monthFromToday = today.plusMonths ( 1 ) ;
  15. LocalDate inMonth10 = today.withMonth ( 10 ) ; // 10 = October, per sane numbering in java.time classes.
  16. LocalDate inMonthOctober = today.with ( Month.OCTOBER ) ; // Using enum objects rather than `int` month numbers.
  17.  
  18. System.out.println ( "today: " + today ) ;
  19. System.out.println ( "monthFromToday: " + monthFromToday ) ;
  20. System.out.println ( "inMonth10: " + inMonth10 ) ;
  21. System.out.println ( "inMonthOctober: " + inMonthOctober ) ;
  22. }
  23. }
Success #stdin #stdout 0.22s 61184KB
stdin
Standard input is empty
stdout
today: 2025-04-29
monthFromToday: 2025-05-29
inMonth10: 2025-10-29
inMonthOctober: 2025-10-29