java显示当前美国洛杉矶时间
发布时间:2016-12-28 来源:查字典编辑
摘要:复制代码代码如下:SimpleDateFormatsdf=newSimpleDateFormat("yyyy/MM/ddHH:mm:ss")...
复制代码 代码如下:
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()));