import static java.time.DayOfWeek.SATURDAY;
import static java.time.DayOfWeek.SUNDAY;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.TextStyle;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAdjusters;
import java.util.Locale;

public class Main {
	public static void main(String[] args) {
		// Tests
		process(ZonedDateTime.now(ZoneId.systemDefault()));
		process(ZonedDateTime.of(LocalDate.of(2021, 6, 23), LocalTime.of(10, 20, 30, 123456789),
				ZoneId.systemDefault()));
		process(ZonedDateTime.of(LocalDate.of(2021, 6, 26), LocalTime.of(10, 20, 30, 123456789),
				ZoneId.systemDefault()));
	}

	static long millisBetween(ZonedDateTime start, ZonedDateTime end) {
		return ChronoUnit.MILLIS.between(start, end);
	}

	static boolean isWeekend(ZonedDateTime now) {
		DayOfWeek dow = now.getDayOfWeek();
		return dow == SATURDAY || dow == SUNDAY;
	}

	static void process(ZonedDateTime now) {
		String dow = now.getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.ENGLISH);
		if (isWeekend(now)) {
			System.out.printf("It's %s (a weekend) now. Monday is %d milliseconds ahead.%n", dow,
					millisBetween(now, now.with(TemporalAdjusters.next(DayOfWeek.MONDAY)).toLocalDate()
							.atStartOfDay(ZoneId.systemDefault())));
		} else {
			System.out.printf("It's %s (a weekday) now. Saturday is %d milliseconds ahead.%n", dow,
					millisBetween(now, now.with(TemporalAdjusters.next(DayOfWeek.SATURDAY)).toLocalDate()
							.atStartOfDay(ZoneId.systemDefault())));
		}
	}
}