📜  按时区获取日期java代码示例

📅  最后修改于: 2022-03-11 14:52:12.432000             🧑  作者: Mango

代码示例1
Date date = new Date();
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

// Use Madrid's time zone to format the date in
df.setTimeZone(TimeZone.getTimeZone("Europe/Madrid"));

System.out.println("Date and time in Madrid: " + df.format(date));