java显示当前美国洛杉矶时间

复制代码 代码如下:

SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Calendar calendar = Calendar.getInstance();
sdf.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles"));
System.out.println("Los_Angeles :"+sdf.format(calendar.getTime()));
sdf.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
System.out.println("Shanghai: "+sdf.format(calendar.getTime()));

你可能感兴趣的:(java显示当前美国洛杉矶时间)