我在DB中存储了这个时间框架:伦敦(BST)的15:00到16:00的任何一天
当我在此时间帧之间收到事件时,我需要执行一个程序IF.
我现在在巴黎(16:22)运行测试,在伦敦是15:22(因此在存储在数据库中的时间帧之间).
这是我的代码
// create Local Date Time from what I have stored in the DB
LocalDateTime dateTime1 = LocalDateTime.of(2017, Month.JUNE, 15, 15, 00);
LocalDateTime dateTime2 = LocalDateTime.of(2017, Month.JUNE, 15, 16, 00);
Instant now = Instant.now();
System.out.println (now.isAfter (dateTime1.atZone(ZoneId.of("BST", ZoneId.SHORT_IDS)).toInstant()));
System.out.println (now.isBefore(dateTime2.atZone(ZoneId.of("BST", ZoneId.SHORT_IDS)).toInstant()));
理论上现在(在巴黎16:22 /伦敦15:22)是在伦敦(15:00)的dateTime1之后和伦敦的dateTime2(16:00)之前
但我现在不是那个dateTime2之前的那个