Java 时钟 class 没有给我当前时间

Java Clock class does not give me the current time

我尝试使用时钟 class 来获取当前时间。

public class TestClock {
  public static void main(String[] args) {
    Clock c = Clock.systemDefaultZone();
    System.out.println(c.instant());
  }
}

但问题是它没有给我当前时间, 但它给出:

(the current time - 3 hours)

所以我决定更加精确,并在程序中指定我居住的城市。(贝鲁特)

public class TestClock {
  public static void main(String[] args) {
    ZoneId zone = ZoneId.of("Asia/Beirut");
    Clock c = Clock.system(zone);
    System.out.println(c.instant());
  }
}

另外,它给了我:

(the current time - 3 hours).

那么问题出在哪里呢?

注:黎巴嫩-贝鲁特时间+3格林威治,这个信息和我的问题有关系吗?

就像@Erwin Bolwidt 指出的那样,请使用 ZonedDateTime 并通过该区域。

public class TestClock {
    public static void main(String[] args) {
        ZoneId zone = ZoneId.of("Asia/Beirut");
        ZonedDateTime zdt = ZonedDateTime.now(zone);
        System.out.println(zdt);
    }
}

结果:

2019-06-11T10:07:20.447+03:00[Asia/Beirut]