Multiple Timezones

From Documentation
Revision as of 09:05, 17 January 2022 by Hawk (talk | contribs) (replace tt with code (via JWB))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Multiple Timezones



In ZK Calendar the default time zone is the first timezone which was added. If no time zone was entered then the system’s time zone is taken as default (by java.util.TimeZone.getDefault()). All the dates in the Calendar component use UTC coordinated universal time. If you wish to show the date and time with regard to your settings you need to use the function getDefaultTimeZone() to retrieve the local time and use that to format your date and time.

For example:

SimpleDateFormat create_sdf = new SimpleDateFormat("HH:mm");
create_sdf.setTimeZone(calendars.getDefaultTimeZone());
				
Calendar cal = Calendar.getInstance(org.zkoss.util.Locales.getCurrent());
String[] times = create_sdf.format(evt.getBeginDate()).split(":");		
int hours = Integer.parseInt(times[0])*2;
int mins = Integer.parseInt(times[1]);
if (mins >= 30) hours++;
createEvent.getFellow("ppbt").setSelectedIndex(hours);


The above example is used to display the correct time of day in a Listbox.


The example project is at Github


Last Update : 2022/01/17

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.