dobry Wojciech

//This should work
TimeZone timeZone = TimeZone.getTimeZone("Europe/Warsaw");
//If  "Europe/Waraw" is not valid this will always work
//TimeZone timeZone = TimeZone.getTimeZone("GMT+1").
GregorianCalendar cal = new GregorianCalendar(timeZone, Locale.EU);

int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH) + 1;
int day = cal.get(Calendar.DAY_OF_MONTH);
int hour = cal.get(Calendar.HOUR);
int minute = cal.get(Calendar.MINUTE);
int second = cal.get(Calendar.SECOND);

//Verify to display warsaw time
System.out.println(year + "-" + month + "-" + day + ", " + hour + ":" + minute + ":" + second);

//IN any case we can update the session variable with the current time
UserSession us = new UserSession(loggedUser);
Timestamp loginTime = new Timestamp(cal.getTimeInMillis());
us.setLoginTime(loginTime);

request.getSession().setAttribute(USER_SESSION, us);

dobrzy?
Martin-

----- Original Message ----- From: "Wojciech Ciesielski" <[EMAIL PROTECTED]>
To: "'Struts Users Mailing List'" <user@struts.apache.org>
Sent: Sunday, September 18, 2005 8:59 AM
Subject: Timezone


Hi there,



I have web-app deployed on JBoss and I am having some problems with date
objects :-/ I am trying to set login time to some bean and display this info
on page. In my LoginAction I do:



UserSession us = new UserSession(loggedUser);

TimeZone tz = TimeZone.getTimeZone("Europe/Warsaw");

GregorianCalendar cal = new GregorianCalendar(tz);

Timestamp loginTime = new Timestamp(cal.getTimeInMillis());

us.setLoginTime(loginTime);

request.getSession().setAttribute(USER_SESSION, us);



and on my JSP page:

<bean:write name="userSession" scope="session" property="loginTime"  />



But the problem is that it takes GMT timezone every time and I am in Poland (CET +01). What should I do to get string with current time in my timezone ?



TIA

Wojtek



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to