获取指定时区的日期和日期时间

public class TokyoDateTime {

    // 获取东京日期
    public static LocalDate getTokyoDate(){
        LocalDateTime localDateTime = LocalDateTime.now();
        ZonedDateTime zonedDateTime = localDateTime.atZone(ZoneId.of("Asia/Tokyo"));
        return zonedDateTime.toLocalDate();
    }
    // 获取东京日期时间
    public static LocalDateTime getTokyoDateTime(){
        LocalDateTime localDateTime = LocalDateTime.now();
        ZonedDateTime zonedDateTime = localDateTime.atZone(ZoneId.of("Asia/Tokyo"));
        return zonedDateTime.toLocalDateTime();
    }
}

你可能感兴趣的:(笔记,java,java,timezone)