0

Calendars timezone

asked 2009-12-31 07:46:26 +0800

kar gravatar image kar
66 2

Hi all,

i wanted to ask a question about the timezone and the calendars

I’m using the zk version 3.6.3.

By default it gets the timezone from California … I have tried adding the rome time zone (so I can see the two columns) but still the hours on the left side starts from 00:00.

What shall I do to correctly display it around the current time?

The setTimeZone wants a string as a value … I have tried putting different values … but I get an exception of array index bound exception …

Thanks
Kar

delete flag offensive retag edit

3 Replies

Sort by » oldest newest

answered 2010-01-03 20:07:42 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

The main timezone always start at 00:00
you can call setTimeZone("California=GMT-8")

link publish delete flag offensive edit

answered 2010-02-05 07:23:13 +0800

kar gravatar image kar
66 2

Hope is not too last to ask still a bit of help ...
here is what i have done ...

org.zkoss.calendar.Calendars cals = (org.zkoss.calendar.Calendars) calendarWin
.getVariable("cal", false);

Map zone = cals.getTimeZones();
if (!zone.isEmpty()) {
Iterator iterator = zone.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry me = (Map.Entry) iterator.next();
// Remove default timezone
cals.removeTimeZone((TimeZone) me.getKey());
}
}
// Add Rome as timezone
cals.addTimeZone("Roma", TimeZone.getTimeZone("Europe/Rome"));
cals.setTimeZone("California=GMT-6"); <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<


so what i do is to remove all time zone from the calendar ...

i have tried different combination ... but
if i had just the addTimeZone (rome ... ) i still see the calendar starting from zero ...
if I had only the second line i get the calendar with name California but still starting from zero ...

if i use both the line i get the first column Roma starting from zero and the second California starting from 16

still do not understand what i'm doing wrong

thanks agains
kar

link publish delete flag offensive edit

answered 2010-02-05 19:23:52 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

You can see that they do the same thing

	public void addTimeZone(String label, TimeZone timezone) {
		if (label == null) label = "";
		_tzones.put(timezone, label);
		
		if (!inMonthMold() && _dfmter != null){
			Calendar cal = Calendar.getInstance(getDefaultTimeZone());			
			cal.set(Calendar.MINUTE, 0);
			smartUpdate("captionByTimeOfDay", Util.encloseList(Util.packCaptionByTimeOfDay(cal, _tzones, Locales.getCurrent(), _dfmter)));
		}
		
		TimeZone tz = getDefaultTimeZone();
		smartUpdate("tz", (tz.getRawOffset() + (tz.useDaylightTime() ? tz.getDSTSavings() : 0))/60000);
		smartUpdate("bd", getBeginDate().getTime());
		smartUpdate("ed", getEndDate().getTime());	
		reSendEventGroup();	
	}

	public void addTimeZone(String label, String timezone) {
		addTimeZone(label, TimeZone.getTimeZone(timezone));
	}

	public void setTimeZone(String timezone) {
		if (timezone == null)
			throw new IllegalArgumentException("The timezone is null!");
		
		for (String timezoneString : timezone.trim().split(",")) {
			String[] pair = timezoneString.split("=");
			addTimeZone(pair[0].trim(), pair[1].trim());
		}
	}

and it will call for loop to draw time zone column
the first element will show start with 00:00
so, which are you want to be base time that start from 00:00 ?
California?
you have to add time zone in you want sequence

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-12-31 07:46:26 +0800

Seen: 619 times

Last updated: Feb 05 '10

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More