import java.time.LocalTime;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

class SchedulingTest {
    public static void main(String[] args) {
        ZonedDateTime startDateTime = ZonedDateTime.now().withSecond(0);
        long startDelay = startDateTime.toInstant().toEpochMilli() - System.currentTimeMillis();

        ScheduledExecutorService executor = new ScheduledThreadPoolExecutor(1);
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("ss");
        executor.scheduleAtFixedRate(
                () -> System.out.println(formatter.format(LocalTime.now())),
                startDelay,
                TimeUnit.SECONDS.toMillis(10),
                TimeUnit.MILLISECONDS
        );
    }
} 