1Date date = new Date();
2DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
3
4// Use Madrid's time zone to format the date in
5df.setTimeZone(TimeZone.getTimeZone("Europe/Madrid"));
6
7System.out.println("Date and time in Madrid: " + df.format(date));