Skip to Main Content

Application Development Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem with SimpleDateFormat (CommandLine vs WebApp)

392220Oct 6 2008 — edited Oct 7 2008
Hello Friends,

I have a strange problem. Not sure what is the mistake from my side. I have simple class that returns formatted date based on TimeZone. It gives me different result if run on command line vs when used in web app (weblogic portal app). Below is the code & other information.

import java.util.*;
import java.text.*;

public class Test {

public static String getDateFormatted(String tZone) {
DateFormat dfm = new SimpleDateFormat("dd-MMMM-yyyy HH:mm:ss z");
dfm.setTimeZone(TimeZone.getTimeZone(tZone));
return dfm.format(new Date());
}

public static void main(String ar[]) {
System.out.println(getDateFormatted(ar[0]));
}

}

Output From Command Prompt
java Test PST
06-October-2008 20:37:01 PDT


Output From webapp running on Weblogic Server Version 10.0
06-October-2008 23:37:04 GMT-04:00


Java version from my command prompt
java version "1.6.0_06"
Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
Java HotSpot(TM) Client VM (build 10.0-b22, mixed mode, sharing)


To confirm if this problem is due to JRockit that is used as default for Weblogic, I changed Java Home in setDomainEnv.cmd to Sun JDK. But still no luck.

set BEA_JAVA_HOME=C:\bea\jrockit_150_11

set SUN_JAVA_HOME=C:\bea\jdk150_11

if "%JAVA_VENDOR%"=="BEA" (
set JAVA_HOME=%SUN_JAVA_HOME%
) else (
if "%JAVA_VENDOR%"=="Sun" (
set JAVA_HOME=%SUN_JAVA_HOME%
) else (
set JAVA_VENDOR=Sun
set JAVA_HOME=C:\bea\jdk150_11
)
)

Thanks & Appreciate any suggestions

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Nov 4 2008
Added on Oct 6 2008
1 comment
289 views