cancel
Showing results for 
Search instead for 
Did you mean: 

Calendar & TimeZone problem

Former Member
0 Kudos

Im developping a mobile application where the mobile devices and the SAP server are in a different timezone. I have tried a couple of things to do that but nothing seems to work..

We are using:

CrEme J2ME(tm)

CrEme V3.25 (=> Personal Java 3.1)

Mobile Engine version: ME 2.1 SP 03 Patch 00 Build 200403030929

I know this is rather old, but this is only a port of an existing application so I would rather not change the setup.

In the business object we have:

public void setSddat(Calendar sddat);

This was called in the originally application like this:

zitm004.setSddat(new GregorianCalendar());

Now with different timezones i have tryed to change the timezone of the GregorianCalendar().

TimeZone tz = TimeZone.getTimeZone("ECT");

Calendar calendar = new GregorianCalendar();

calendar2.setTimeZone(tz);

zitm004.setSddat(calendar);

This is not working. However following code showed me the right time:

TimeZone tz = TimeZone.getTimeZone("ECT");

Date now = new Date();

SimpleDateFormat sdf = new SimpleDateFormat();

sdf.setTimeZone(tz);

Log.log(Log.DEVELOP_LEVEL,"sdf.format(now):" + sdf.format(now));

I also tried setting the timezone in MobileEngine.conf using:

MobileEngine.Sync.Timezone=ECT or

MobileEngine.Sync.Timezone=Europe/Brussels

This is not working, and i think my mobile engine does not support this setting yet as i dont see anything about timezone appearing in the trace.

Any ideas?

Thanks,

Hannes

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

hi hannes,

can you try using:

Calendar.getInstance(TimeZone.getTimeZone("ECT"));

or try adding

calendar.setTimeZone(tz);
calendar.getTime(); //<<--- added line
zitm004.setSddat(calendar);

i remember there was a bug in the Calendar implementation in the early JDK1.1

which is the base of Personal Java. (something related to the setTimeZone method

that doesn't do the recalculation until the getTime method is invoked.)

not sure if it works but might worth a try.

regards

jo

Former Member
0 Kudos

Thanks but that did not solve the problem. Looking at bugs.sun.com there seems indeed to be a bug in JDK1.1.

However the customer does not think its that important for now, and otherwise i guess ill have to change the time in ABAP.

Greetings,

Hannes

Former Member
0 Kudos

Hello,

Can I suggest to process all time in GMT? Display it with the current time zone, but save it and sync it in GMT format. In the backend (BADI or BAPI) change the time zone to the one in the backend (the backend is always saving in GMT I think, not sure).

Thank you,

Julien.

Former Member
0 Kudos

Julien,

I understand this is indeed the best solution. However, having this problem I have to pass a calendar object of which i cannot change the timezone, so I cannot change it to GMT time.

Thanks,

Hannes