public static void main(String[] args) {
// 1、使用ZoneId定义美国时区
ZoneId zoneId = ZoneId.of("America/New_York");
// 2、获取当前时间
ZonedDateTime now = ZonedDateTime.now();
// 3、将当前时间转换为美国时间
ZonedDateTime zonedDateTime = now.withZoneSameInstant(zoneId);
// 4、定义格式输出
DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String format = zonedDateTime.format(dateFormat);
System.out.println(format);
// 转换时间对象
Date date = MyDateUtil.dateStrToDate("yyyy-MM-dd HH:mm:ss", format);
System.out.println(MyDateUtil.dateToDateStr(date));
}