/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

import java.time.*;
import java.time.temporal.*;
import java.time.format.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
        LocalDate target = LocalDate.of( 2017 , Month.JANUARY , 1 );
        LocalDate ld = target.with( TemporalAdjusters.previousOrSame( DayOfWeek.MONDAY ) );

        LocalDate nextOrSameSunday = target.with( TemporalAdjusters.nextOrSame( DayOfWeek.SUNDAY ) );

        System.out.println( "target: " + target + " | ld: " + ld  + " | nextOrSameSunday: " + nextOrSameSunday );

        ZoneId z = ZoneId.of( "America/Montreal" );
        DateTimeFormatter f = DateTimeFormatter.ofLocalizedDate( FormatStyle.FULL ).withLocale( Locale.CANADA );
        System.out.println( "target: " + target.format( f ) + " | ld: " + ld.format( f ) );
	}
}