You are here: Home / Extensions / Java Time Zones

Java Time Zones

Warning
This product has not had a release in over 1 year and may no longer be maintained.

Converts dates between time zones. Re-formats dates. Performs date arithmetic according to calendar.

Project Description

The extensions manages dates via Java built-in classes: GregorianCalndar, TimeZone, SimpleDateFormat, Locale.


Extension's functions:
===============
[Array] means an array formula i.e. press [Ctrl+Shift+Enter]

* Date string functions
jtz_date_reformat
jtz_date_add
jtz_date_tz
jtz_date_tz_offset
jtz_date_is_dst
jtz_date_parse
jtz_date_split [Array]

* Unix time (milliseconds) functions
jtz_unix_add
jtz_unix_now
jtz_unix_format
jtz_unix_is_dst
jtz_unix_split [Array]
jtz_unix_tz_offset
jtz_unix_timer
jtz_unix_timer_split [Array]

* Information functions
jtz_format_codes [Array]
jtz_loc_ids [Array]
jtz_tz_ids [Array]
jtz_tz_loc
jtz_tz_info [Array]
jtz_tz_by_raw_offset [Array]

* Values in milliseconds
jtz_mls_hour
jtz_mls_minute
jtz_mls_second

* Date fields
jtz_f_year
jtz_f_month
jtz_f_day
jtz_f_hour
jtz_f_minute
jtz_f_second
jtz_f_millis
jtz_f_raw_offset
jtz_f_dst_offset
jtz_f_total_offset


About time zones
===========
* Greenwich Mean Time (GMT) is an absolute time reference and it doesn't change with the seasons. Each time zone has constant RAW offset from GMT. But some of them use an additional offset called Daylight Saving Time (DST). Finally, we can say that each time zone has TOTAL_OFFSET = RAW_OFFSET + DST_OFFSET. Some zones don't use DST i.e. DST_OFFSET = 0

* Unix time is defined as the number of milliseconds from:
"1970-01-01 00:00:00.000 GMT"

* A point in time expressed as Unix time has the same graphical representation in all time zones. On the other hand, a point in time expressed as "plain date" can vary depending on a time zone, e.g.
a Unix time:
"1319568508751"
in Poland means:
"2011-10-25 20:48:28.751 CEST"
but in Greece:
"2011-10-25 21:48:28.751 EEST"
So, all three dates describe the same point in time despite they have different graphical representations.


Priority and default values of parameters
============================
* A time zone can be read from a date using "z" format code or it can be given by "time zone ID" parameter. Remember, time zone in a date format ("z" code) has higher priority than "time zone ID" i.e. if a date format contains "z" then "time zone ID" parameter is ignored.

* If a date format doesn't contain "z" code and "time zone ID" parameter is skipped or it's empty then "GMT" time zone is used.

* If "locale ID" parameter is skipped or it's empty then a default locale of your Java Virtual Machine is used.

* Note a subtle thing that a time zone included in a date string e.g. (CET or CEST) carries more information that a time zone given by its ID e.g. "Europe/Warsaw". Most of the time there is no difference except the moment of DST change. E.g. in year 2011 in "Europe/Warsaw" we disabled DST at:
"2011-10-30 03:00:00.000 CEST"
by pushing back clocks to:
"2011-10-30 02:00:00.000 CET"
Finally if we have only time zone ID like:
"Europe/Warsaw"
and any time between:
"2011-10-30 02:00:00.000" and
"2011-10-30 03:00:00.000"
we don't know if it is:
"CEST" or "CET"
Finally, use a time zone included in a date ("z" format code) wherever possible. If you have a date with a general time zone ID only, be careful because sometimes it is not strict.


Tutorial:
=======
* Get unix time
In: jtz_unix_now()
Out: 1319568508751

* But what does it mean in Poland?
In: jtz_unix_format(1319568508751; "yyyy-MM-dd HH:mm:ss.S z"; "Europe/Warsaw")
Out: 2011-10-25 20:48:28.751 CEST

* In Greece?
In: jtz_unix_format(1319568508751; "yyyy-MM-dd HH:mm:ss.S z"; "Europe/Athens")
Out: 2011-10-25 21:48:28.751 EEST

* How to read date format?
In: jtz_format_codes() [Array]
Out: G | Era designator
...

Date format codes are case sensitive, "M" is for moth but "m" is for "minute".
Some codes can be repeated e.g. "MMM" gives short month name, "MMMM" gives long month name.

* Where can I find time zones IDs like "Europe/Warsaw"?
In: jtz_tz_ids() [Array]
Out: ACT | CST | Central Standard Time (Northern Territory) | CST | Central Summer Time (Northern Territory)
...

where columns mean:
[1] time zone ID
[2] short RAW name
[3] long RAW name
[4] short DST name
[5] long DST name

You can search for particular time zone ID:
In: jtz_tz_ids(0; "en"; "Eur"; "Wars") [Array]

where parameters are:
[1] if (<> 1) then search is performed only in default locale,
if (== 1) then search is performed in ALL locales supported by Java
[2] output locale; Time zones IDs are the same in all locales but time zones
names can differ.
[3] search string
[4] search string
[...] more search strings

To Be Continued...

Self-Certification

[ ] Internationalized

[ ] Unit tests

[ ] End-user documentation

[ ] Internal documentation (documentation, interfaces, etc.)

[ ] Existed and maintained for at least 6 months

[X] Installs and uninstalls cleanly

[ ] Code structure follows best practice

Current Release
Java Time Zones 0.2.0

Released Oct 31, 2011 — tested with LibreOffice 3.4

Before installation please remove previous version and restart L/OOo
More about this release…

Download file Get Java Time Zones for All platforms
JavaTimeZonesAddIn_0.2.0.oxt
Download file Get Java Time Zones for All platforms
JavaTimeZones_0.2.0_source.zip
If you don't know, how to install an extension in LibreOffice, see our howto about installing extension for detailed instructions.

All Releases

Version Released Description Compatibility Licenses Status
0.2.0 Oct 31, 2011 Before installation please remove previous version and restart L/OOo More about this release…
LibreOffice 3.4
GPL-v3 final
0.1.1 Oct 30, 2011 Bugfixes for 0.1.0 More about this release…
LibreOffice 3.4
GPL-v3 final
0.1.0 Oct 24, 2011 First release. More about this release…
LibreOffice 3.4
GPL-v3 final
Donate

LibreOffice is made available by volunteers around the globe, backed by a charitable Foundation. Please support our efforts: Your donation helps us to deliver a better product!


Legal Disclaimers and Limitations | Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0. License. This does not include the source code of LibreOffice, which is licensed under the GNU Lesser General Public License ( LGPL v.3 ).

"LibreOffice" and "The Document Foundation" are registered trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.