Java websphere jre时区不正确

Java websphere jre时区不正确,java,websphere,Java,Websphere,我们有两台linux应用服务器,都安装了WebSphere6.1。我已经编写了一个简单的独立java应用程序来打印当前时间 public static void main(String[] args) { TimeZone tz = TimeZone.getDefault(); System.out.println("the default timezone is " + tz.getDisplayName(true, TimeZone.L

我们有两台linux应用服务器,都安装了WebSphere6.1。我已经编写了一个简单的独立java应用程序来打印当前时间

    public static void main(String[] args) {
            TimeZone tz = TimeZone.getDefault();
            System.out.println("the default timezone is " + tz.getDisplayName(true, TimeZone.LONG));
            System.out.println("the default timezone ID is " + tz.getID());
            System.out.println("useDaylightTime = " + tz.useDaylightTime());
    }
在box应用服务器a上,我得到

在box应用服务器b上,我得到

我希望应用服务器b与a相同。有人能帮我做些什么来实现这一点吗


感谢使用getDefault方法,如果不缓存,Java将

Use the user.timezone property value as the default time zone ID if it's available.
Detect the platform time zone ID.
Use GMT as the last resort if the given or detected time zone ID is unknown.
根据报告的输出,应用程序服务器b似乎没有设置user.timezone属性。 根据,您可以按照以下步骤设置时区

1. Start the administrative console.
2. In the topology tree, expand Servers >> Application Servers.
3. Click on application server for which you want to set the time zone
4. On the application server page, click Process Definition>>Java Virtual Machine>>Custom Properties>>New
5. Specify user.timezone in the Name field and timezone in the Value field, where timezone is the supported value for your time zone.
6. Click Apply/ok
7. Save the configuration


ex :  Name - user.timezone
     value - Asia/Singapore
因此,我将验证它是否为您的b系统正确设置。在您的情况下,您将把亚洲/新加坡改为澳大利亚/悉尼


如果上面的过程由于任何原因都不起作用,我只是通过时钟设置来设置你的时区,假设你可以这样做的话,应该可以解决这个问题。我没有可用的Websphere系统来测试它。

您可能想看看@Paul。嗨,我不认为这是一个系统时间问题。当我在命令行中输入日期时,时间是相同的。我认为这是一个java jre时间问题。你的意思是两台机器中的时区相同吗?你的服务器设置为不同的时间设置。美国东部时间和格林尼治标准时间+10相隔一小时。如果您的命令行显示的是同一时间,那么设置就不一样了。@CharlieS我读了您的评论好几次,但我很难理解它。当我发出以下命令时,在框a和框b的命令行上:date和zdump:/etc/localtime,两个框上的输出是相同的。我不明白你说的是什么意思,如果命令行说的是相同的,那么它们就不一样了?感谢您的评论。我已经检查了框b中user.timezone的websphere控制台,但它不是作为自定义属性存在的。我猜这意味着它是在使用平台时区id。但我认为这两个框上的设置都是相同的。请参阅我对@Charlie的评论。您是否能够尝试按照步骤4将其添加为新的自定义属性,或者该选项不可用?我相信不存在的属性可以解释问题,因为它将默认为GMT时间。这不是在两台机器上都设置的,所以最初我没有尝试设置它,但我只是尝试在框a上设置它,猜猜看。。。成功了!谢谢不过我的两个盒子还是有些不同。但没关系。谢谢你的帮助
Use the user.timezone property value as the default time zone ID if it's available.
Detect the platform time zone ID.
Use GMT as the last resort if the given or detected time zone ID is unknown.
1. Start the administrative console.
2. In the topology tree, expand Servers >> Application Servers.
3. Click on application server for which you want to set the time zone
4. On the application server page, click Process Definition>>Java Virtual Machine>>Custom Properties>>New
5. Specify user.timezone in the Name field and timezone in the Value field, where timezone is the supported value for your time zone.
6. Click Apply/ok
7. Save the configuration


ex :  Name - user.timezone
     value - Asia/Singapore