在 Java 中,可以使用Instant
类来获取指定时间的时间戳。
首先,你需要使用ZonedDateTime
类来表示指定的时间。你可以使用ZonedDateTime.of
方法来创建一个ZonedDateTime
对象,并传入时间的年份、月份、日期、小时数、分钟数、秒数和时区信息:
ZonedDateTime zonedDateTime = ZonedDateTime.of(, 1, 1, 0, 0, 0, 0, ZoneId.of("Asia/Shanghai"));
然后,你可以使用Instant
类的from
方法来将ZonedDateTime
对象转换为时间戳:
Instant instan