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. import java.time.temporal.* ;
  9. import java.time.format.* ;
  10.  
  11.  
  12. /* Name of the class has to be "Main" only if the class is public. */
  13. class Ideone
  14. {
  15. public static void main (String[] args) throws java.lang.Exception
  16. {
  17.  
  18. long weekOfYear = 27 ; // 1-52 or 1-53 for ISO 8601 week-based years.
  19. long dayOfWeek = 2 ; // 1-7 for Monday-Sunday, per ISO 8601 standard.
  20.  
  21. LocalDate today = LocalDate.now( ZoneId.of( "America/Montreal" ) ) ;
  22. LocalDate adjusted = today.with( WeekFields.ISO.weekOfWeekBasedYear(), weekOfYear )
  23. .with( WeekFields.ISO.dayOfWeek(), dayOfWeek ) ;
  24.  
  25. System.out.println( "2017-W27-02: " + adjusted ) ;
  26.  
  27. }
  28. }
Success #stdin #stdout 0.24s 35060KB
stdin
Standard input is empty
stdout
2017-W27-02: 2017-07-04