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.format.* ;
  9. import java.time.temporal.* ;
  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. LocalDate ld = LocalDate.parse( "2019-01-23" ) ;
  19.  
  20. TemporalAdjuster ta = TemporalAdjusters.previous( DayOfWeek.MONDAY ) ;
  21. LocalDate previousMonday = ld.with( ta ) ;
  22.  
  23. DateTimeFormatter f = DateTimeFormatter.ofLocalizedDate( FormatStyle.FULL ).withLocale( Locale.US ) ;
  24. String output = previousMonday.format( f ) ;
  25.  
  26. System.out.println( "previousMonday = " + previousMonday ) ;
  27. System.out.println( "output: " + output ) ;
  28.  
  29.  
  30. }
  31. }
Success #stdin #stdout 0.17s 39692KB
stdin
Standard input is empty
stdout
previousMonday = 2019-01-21
output: Monday, January 21, 2019