当前位置: 编程技术>java/j2ee
java显示当前美国洛杉矶时间
来源: 互联网 发布时间:2014-11-03
本文导语: 代码如下: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/Sha...
代码如下:
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()));