// Path: src/main/java/net/atos/entng/rbs/models/BookingDateUtils.java
// public class BookingDateUtils {
// 	public static long secondToDays(long seconds) {
// 		return TimeUnit.DAYS.convert(seconds, TimeUnit.SECONDS);
// 	}
// 
// 	public static ZonedDateTime addDaysIgnoreDST(ZonedDateTime base, int plusNbDays) {
// 		ZonedDateTime result = base.plusDays(plusNbDays);
// 		if (result.getHour() != base.getHour()) {
// 			result.withHour(base.getHour());
// 		}
// 		return result;
// 	}
// 
// 	public static long daysToSecond(long days) {
// 		return TimeUnit.SECONDS.convert(days, TimeUnit.DAYS);
// 	}
// 
// 	public static long currentTimestampSecondsForIana(String iana) {
// 		return ZonedDateTime.now(ZoneId.of(iana)).toEpochSecond();
// 	}
// 
// 	public static int nextDayOfWeek(final int currentDayOfWeek, final int plusDays) {
// 		return (currentDayOfWeek + plusDays) % 7;
// 	}
// 
// 	public static long tomorrowTimestampSecondsForIana(String iana) {
// 		// Get tomorrow by adding one day to current time
// 		ZonedDateTime today = ZonedDateTime.now(ZoneId.of(iana));
// 		today = today.truncatedTo(ChronoUnit.DAYS);
// 		ZonedDateTime tomorrowMidnight = today.plusDays(1);
// 		return tomorrowMidnight.toEpochSecond();
// 	}
// 
// 	/**
// 	 *
// 	 * @param unixTimestamp in seconds
// 	 * @return 0 for sunday, 1 for monday, etc
// 	 */
// 	public static int dayOfWeekForTimestampSecondsAndIana(final long unixTimestamp, String iana) {
// 		Instant i = Instant.ofEpochSecond(unixTimestamp);// UTC
// 		ZonedDateTime z = ZonedDateTime.ofInstant(i, ZoneId.of(iana));// LOCAL
// 		// %7 so that sunday is 0, monday is 1, etc
// 		return z.getDayOfWeek().getValue() % 7;
// 	}
// 
// 	public static ZonedDateTime localDateTimeForTimestampSecondsAndIana(long timestampSeconds, String iana) {
// 		Instant i = Instant.ofEpochSecond(timestampSeconds);// UTC
// 		ZonedDateTime z = ZonedDateTime.ofInstant(i, ZoneId.of(iana));// LOCAL
// 		return z;
// 	}
// 
// 
// }


import java.time.Instant;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.zone.ZoneOffsetTransition;
import java.time.zone.ZoneRules;
import java.util.Date;
import org.junit.Assert;
import org.junit.Test;
import net.atos.entng.rbs.models.BookingDateUtils;
		ZonedDateTime after = nextTransition.getInstant().atZone(ZoneId.of(IANA_PARIS)).plusDays(1);
		System.out.println("Before transition : " + before);
		System.out.println("Before transition no zoned : " + Date.from(before.toOffsetDateTime().toInstant()));
		System.out.println("Before UTC: " + before.toEpochSecond());
		// moment.utc(...).tz("Europe/paris").format("DD/MM/YYYY HH:mm")
		System.out.println("Before UTC 2:00: " + before.toLocalDateTime().withHour(2).withMinute(0));
		System.out.println("Before UTC 2:00 at offset utc: "
				+ before.toLocalDateTime().withHour(2).withMinute(0).toEpochSecond(ZoneOffset.UTC));
		// => moment.utc(...).format("DD/MM/YYYY HH:mm")
		long beforeUTCTimestamp = before.toEpochSecond();
		System.out.println("Before transition reverse UTC: "
				+ ZonedDateTime.ofInstant(Instant.ofEpochSecond(beforeUTCTimestamp), ZoneId.of(IANA_PARIS)));
		System.out.println("Transition : " + transition);
		System.out.println("After transition : " + after);
		System.out.println("After UTC : " + after.toEpochSecond());
		// moment.utc(...).tz("Europe/paris").format("DD/MM/YYYY HH:mm")
		System.out.println("After UTC 2:00: " + after.toLocalDateTime().withHour(2).withMinute(0));
		System.out.println("After UTC 2:00 at offset utc: "
				+ after.toLocalDateTime().withHour(2).withMinute(0).toEpochSecond(ZoneOffset.UTC));
		// => moment.utc(...).format("DD/MM/YYYY HH:mm")
	}

	@Test
	public void shouldAddDayIgnoreDST() {
		ZoneId zoneId = ZoneId.of(IANA_PARIS);
		ZoneRules rules = zoneId.getRules();
		ZoneOffsetTransition nextTransition = rules.nextTransition(Instant.now());
		Instant transition = nextTransition.getInstant();
		ZonedDateTime before = nextTransition.getInstant().atZone(ZoneId.of(IANA_PARIS)).plusDays(-1);
		before = before.withHour(10).withMinute(0);
// Path: src/main/java/net/atos/entng/rbs/models/BookingDateUtils.java
// public class BookingDateUtils {
// 	public static long secondToDays(long seconds) {
// 		return TimeUnit.DAYS.convert(seconds, TimeUnit.SECONDS);
// 	}
// 
// 	public static ZonedDateTime addDaysIgnoreDST(ZonedDateTime base, int plusNbDays) {
// 		ZonedDateTime result = base.plusDays(plusNbDays);
// 		if (result.getHour() != base.getHour()) {
// 			result.withHour(base.getHour());
// 		}
// 		return result;
// 	}
// 
// 	public static long daysToSecond(long days) {
// 		return TimeUnit.SECONDS.convert(days, TimeUnit.DAYS);
// 	}
// 
// 	public static long currentTimestampSecondsForIana(String iana) {
// 		return ZonedDateTime.now(ZoneId.of(iana)).toEpochSecond();
// 	}
// 
// 	public static int nextDayOfWeek(final int currentDayOfWeek, final int plusDays) {
// 		return (currentDayOfWeek + plusDays) % 7;
// 	}
// 
// 	public static long tomorrowTimestampSecondsForIana(String iana) {
// 		// Get tomorrow by adding one day to current time
// 		ZonedDateTime today = ZonedDateTime.now(ZoneId.of(iana));
// 		today = today.truncatedTo(ChronoUnit.DAYS);
// 		ZonedDateTime tomorrowMidnight = today.plusDays(1);
// 		return tomorrowMidnight.toEpochSecond();
// 	}
// 
// 	/**
// 	 *
// 	 * @param unixTimestamp in seconds
// 	 * @return 0 for sunday, 1 for monday, etc
// 	 */
// 	public static int dayOfWeekForTimestampSecondsAndIana(final long unixTimestamp, String iana) {
// 		Instant i = Instant.ofEpochSecond(unixTimestamp);// UTC
// 		ZonedDateTime z = ZonedDateTime.ofInstant(i, ZoneId.of(iana));// LOCAL
// 		// %7 so that sunday is 0, monday is 1, etc
// 		return z.getDayOfWeek().getValue() % 7;
// 	}
// 
// 	public static ZonedDateTime localDateTimeForTimestampSecondsAndIana(long timestampSeconds, String iana) {
// 		Instant i = Instant.ofEpochSecond(timestampSeconds);// UTC
// 		ZonedDateTime z = ZonedDateTime.ofInstant(i, ZoneId.of(iana));// LOCAL
// 		return z;
// 	}
// 
// 
// }


// Path: src/test/java/net/atos/entng/rbs/test/units/BookingDateTest.java
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.zone.ZoneOffsetTransition;
import java.time.zone.ZoneRules;
import java.util.Date;
import org.junit.Assert;
import org.junit.Test;
import net.atos.entng.rbs.models.BookingDateUtils;

		ZonedDateTime after = nextTransition.getInstant().atZone(ZoneId.of(IANA_PARIS)).plusDays(1);
		System.out.println("Before transition : " + before);
		System.out.println("Before transition no zoned : " + Date.from(before.toOffsetDateTime().toInstant()));
		System.out.println("Before UTC: " + before.toEpochSecond());
		// moment.utc(...).tz("Europe/paris").format("DD/MM/YYYY HH:mm")
		System.out.println("Before UTC 2:00: " + before.toLocalDateTime().withHour(2).withMinute(0));
		System.out.println("Before UTC 2:00 at offset utc: "
				+ before.toLocalDateTime().withHour(2).withMinute(0).toEpochSecond(ZoneOffset.UTC));
		// => moment.utc(...).format("DD/MM/YYYY HH:mm")
		long beforeUTCTimestamp = before.toEpochSecond();
		System.out.println("Before transition reverse UTC: "
				+ ZonedDateTime.ofInstant(Instant.ofEpochSecond(beforeUTCTimestamp), ZoneId.of(IANA_PARIS)));
		System.out.println("Transition : " + transition);
		System.out.println("After transition : " + after);
		System.out.println("After UTC : " + after.toEpochSecond());
		// moment.utc(...).tz("Europe/paris").format("DD/MM/YYYY HH:mm")
		System.out.println("After UTC 2:00: " + after.toLocalDateTime().withHour(2).withMinute(0));
		System.out.println("After UTC 2:00 at offset utc: "
				+ after.toLocalDateTime().withHour(2).withMinute(0).toEpochSecond(ZoneOffset.UTC));
		// => moment.utc(...).format("DD/MM/YYYY HH:mm")
	}

	@Test
	public void shouldAddDayIgnoreDST() {
		ZoneId zoneId = ZoneId.of(IANA_PARIS);
		ZoneRules rules = zoneId.getRules();
		ZoneOffsetTransition nextTransition = rules.nextTransition(Instant.now());
		Instant transition = nextTransition.getInstant();
		ZonedDateTime before = nextTransition.getInstant().atZone(ZoneId.of(IANA_PARIS)).plusDays(-1);
		before = before.withHour(10).withMinute(0);
		ZonedDateTime after = BookingDateUtils.addDaysIgnoreDST(before, 2);