【问题标题】:How to convert date formats from one timezone to another with day light in java [duplicate]如何在java中使用日光将日期格式从一个时区转换为另一种时区[重复]
【发布时间】:2012-12-06 18:06:15
【问题描述】:

可能重复:
Timezone conversion

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

【问题讨论】:

标签: java date datetime timezone dst


【解决方案1】:

你想这样做

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));  

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-01-23
    • 1970-01-01
    • 2022-01-19
    • 1970-01-01
    • 2015-02-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多