如何在java中使用日光将日期格式从一个时区转换为另一个时区



可能的重复项:
时区转换

我想编写一个 java 代码,用于在日光下将日期格式从一个时区转换为另一个时区。我正在使用甲骨文数据库。有什么想法吗?

你想这样做

Date date = new Date();  
DateFormat formatter = new SimpleDateFormat("dd MMM yyyy HH:mm:ss z");  
formatter.setTimeZone(TimeZone.getTimeZone("CET"));  
// Prints the date in the CET timezone  
System.out.println(formatter.format(date));  
// Set the formatter to use a different timezone  
formatter.setTimeZone(TimeZone.getTimeZone("IST"));  
// Prints the date in the IST timezone  
System.out.println(formatter.format(date));  

最新更新