on 07-14-2009 4:49 PM
Hi developers,
in my WDJ, I am calling a webservice which, executed from wsnavigator, returns this time value:
1970-01-01T08:30:47.000Z
On WDJ table I get: 10.30 both with direct binding and computed field such as:
DateFormat df = DateFormat.getTimeInstance(DateFormat.MEDIUM, Locale.getDefault());
return df.format(element.getTimeSent());
The locale the app is in (both from browser and from webdynpro console) is Italy (GMT +1)
So I should see 09.30
Can anyone please help?
Thanks, regards
Vincenzo
Hi,
I think you're getting an 'additional hour' since Italy is currently under Daylight Saving Time. Since you're using the Locale, and Locale should internally use Timezone (which constructs a Default based on JVM system settings), DST is being automatically 'calculated' on your time.
You can check wheter this is effect or not of Timezone settings.
boolean inDayLightTime = TimeZone.getDefault().inDayLightTime(YOUR_DATE_GMT);
Hope it helps.
Regards,
Daniel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Daniel, thanks for your reply.
Actually I dug into the issue debugging what I got is:
WS output:
1970-01-01T09:30:47.000+01:00 (correct)
From the debugger I try to access the java.sql.Time variable and invoke toGMTString():
(java.lang.String) 1 Jan 1970 09:30:47 GMT
WDJ is actually ignoring the timezone (GMT vs GMT+1)
Can anyone please help?
Thanks, regards
Vincenzo
Hi Sergei, thanks for replying
Actually I am invoking this method just to see the GMT value of the timestamp.
getAttributeAsText outputs the "wrong" value 10.30 (timezone = CET ).
Actually on WS provider side the exposed object is java.sql.Time
I know about other projects where GregorianCalendar was used on WS provider, with no such problems
Can this be a type related issue?
Regards
Vincenzo
Vincenzo
I do not think that this is a bug. WD tries to display the date for an end-user having in mind the timezone and also Daylight Saving Time. I agree with Daniel here.
So, for Italy's timezone WD adds +1 for CET and also adds 1 for Summer Time. Result time will be GMT2. Exactly what you see in UI.
BR, Sergei
Hello Sergei,
With regard to the Daylight Saving Time,
the complete value of the java.sql.Timestamp received from the WS is 1970-01-01T08:30:47.000Z (WSNavigator)
I think DST is not applied here.
Actually the error is that WS outputs:
09.30 GMT +1 or (consistently) 08.30 GMT (see above)
but
WDJ receives 9.30 GMT (checked from debugger)
so 9.30 GMT (WDJ) does not equal 9.30 GMT+1 (WS)
(If WDJ had received 08.30 GMT that would be fine, but this is not the case)
WDJ should NOT add one hour, do I get it right?
Thanks, regards
Vincenzo
Hi Vincenzo
Try to check if this is really caused by Daylight Saving Time. You can test this if you switch off Daylight Saving Time feature on your system (OS) and open the WD UI again.
For example, in Win XP I can do this in Date And Time Properties -> uncheck "Automatically adjust clock for daylight saving changes". Then restart IE, log in the WD UI and check the time. It should be 9:30 (GMT+1, CET).
BR, Sergei
Hi Sergei,
I am going to give it a try, but I really doubt that DST would be applied for a date in 1970 (see above).
In the meanwhile we are also testing whether it is the java.sql.Time type the cause of our issues, doing same tests with Gregorian Calendar,
will revert back in a minute
Thanks for your kind help
Vincenzo
>I tried to switch DST management off on client to no use, should I do it on server?
Actually after spend some time thinking I realized that my proposal regarding client's DST settings maybe wrong... Actually I do not know exactly if Webdynpro uses client's timezone or not.
Instead try to debug the peace of code below which gets the timezone of the current logged in user:
TimeZone userTimeZone = WDClientUser.getLoggedInClientUser().getSAPUser().getTimeZone();
boolean inDayLightTime = userTimeZone.inDayLightTime(WS_output_date);
The code will check your time returned by WS against logged in user's timezone. If inDayLightTime = true then DST is enabled for the time.
Hope this will help to understand if DST adds additional hour or not.
BR, Sergei
Hi,
i recommend to use TimeZone class of java for conversion.
Below is the example :
// Suppose this is a date and time in the EST timezone
String value = "2006-11-28 09:45:12";
DateFormat df1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
df1.setTimeZone(TimeZone.getTimeZone("EST"));
// Parses the value and assumes it represents a date and time in the EST timezone
Date d = df1.parse(value);
DateFormat df2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
df2.setTimeZone(TimeZone.getTimeZone("GMT-1:00"));
// Formats the date in the GMT-1:00 timezone
System.out.println(df2.format(d));
hope it helps.
Thanks & Regards,
Aditya metukul
Hi, Sergei, thanks once more for your help.
Actually
com.sap.tc.webdynpro.services.sal.um.api.WDClientUser.getLoggedInClientUser().getSAPUser().getTimeZone();
returns null.
moreover I am forced to use TimeStamps which are not easily handled (only way you can pass to a Date is via long millisec).
@Aditya
How would you handle a date String with timezone in it (es: yyyy-mm-dd hh-mm-ss Zsomething)?
Could you override the timezone specified in the String in the same way?
Thanks
regards
Hi Vincenzo
If the code below returns NULL then more likely the J2EE user was created without any particular timezone specified. Timezone field in Identity Management is empty for the user I think.
WDClientUser.getLoggedInClientUser().getSAPUser().getTimeZone()
In the case you can get server's default timezone:
TimeZone.getDefault()
However, if the Timezone field is specified in Identity Management for some J2EE/Portal user the code shall work, I think.
BR, Sergei
must close, unknown
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.