By default, my Fedora Linux installation comes with the TZ environment variable not set. When Fan queries the system for the current time zone (why is this needed for the Fan shell, by the way? Curious), Java (both JDK 6 / x86 from Sun and OpenJDK 1.6.0 / x64 from Fedora) returns GMT-05:00, which Fan is really unhappy about:
ERROR: Cannot init current timezone
sys::ParseErr: TimeZone not found: GMT-05:00
at fan.sys.ParseErr.<init>(ParseErr.java:65)
at fan.sys.ParseErr.make(ParseErr.java:51)
at fan.sys.ParseErr.make(ParseErr.java:48)
at fan.sys.ParseErr.make(ParseErr.java:21)
at fan.sys.TimeZone.fromStr(TimeZone.java:83)
at fan.sys.TimeZone.fromStr(TimeZone.java:48)
at fan.sys.TimeZone.<clinit>(TimeZone.java:519)
at fan.sys.DateTime.<clinit>(DateTime.java:867)
at fan.sys.Sys.<clinit>(Sys.java:490)
at fan.sys.Pod.readFPod(Pod.java:133)
at fan.sys.Pod.find(Pod.java:61)
at fan.sys.Type.find(Type.java:54)
at fanx.util.TypeParser.load(TypeParser.java:56)
at fan.sys.Type.find(Type.java:51)
at fanx.tools.Fan.executeType(Fan.java:109)
at fanx.tools.Fan.execute(Fan.java:40)
at fanx.tools.Fansh.main(Fansh.java:22)
Setting TZ to America/New_York works, but should this be fixed in Fan, or in Fedora? (Apologies if this should go to the Sourceforge bugtracker instead; there is no bug filed there so I'm not sure if it's being used)
Got here from the Wide Finder project, by the way. Cool language!
-- Michel
andySun 15 Jun 2008
Thanks Michel - we'll take a look. And yeah, we're only using SF for downloads, so this is the correct place to report bugs (eventually there will be formal bug tracking on this site).
brianMon 16 Jun 2008
Yeap - I noticed this problem on Solaris working on WideFinder. I try to map the Java's timezone to an Olsen timezone on startup. On Windows and OS X this seems to work really well. On Unix it seems every variant does things a bit different - which is weird because one would think Unix would always use a clean Olsen tz. I've already added a fix in the code to deal with "GMT0" and "GMT+/-hh:mm". Please let me know if someone is using a variant of Linux that does something else.
But I still think there is a problem in either the OS or the JDK: GMT-5:00 is not the same as America/New_York since it doesn't come with any historical or daylight saving rules. So as a backup you can always set the timezone explicitly in "lib/sys.props".
Stephen is a Java time guru, so maybe he knows more.
msylvanMon 16 Jun 2008
GMT-5 is definitely not EST/EDT -- and even EST/EDT is not unambiguous across different countries.
So it looks like both Linux and Solaris no longer set the TZ environment variable; the common factor seems to be the Java runtime. Looking at it using Scala reveals the oddity: Java is definitely not returning the correct time zone!
The Unix date tool returns PDT and my system timezone is set to "Americas/Los_Angeles" at the moment. I guess a quick fix would be to just add a "US/Pacific" timezone to the timezones.ftz database. Is there some piece of code or script that is used to generate this database?
brianMon 29 Sep 2008
The US/Pacific timezone is in the backward list which was deprecated in 1993 - so it definitely seems odd that all these Java ports to Linux are doing the wrong thing.
It might make more sense to have the Linux bash scripts pass in the tz from the OS and use that to map into the olsen database. I'll take a look.
In the meantime you can always "fix" via lib/sys.props:
// Default timezone to use for VM - can be either the simple name
// or the full name. If not set explicitly, then the we will
// attempt to query the timezone from the Java or .NET runtime
fan.timezone=New_York
brianTue 4 Nov 2008
For those of you running Linux or Solaris I'd be interested in gathering some information.
What does Java report as the default timezone?
import java.util.*;
class TzTest {
public static void main(String[] args) {
System.out.println(java.util.TimeZone.getDefault().getID());
}
}
What does "/etc/localtime" symbolically link to?
ls -l /etc/localtime
Does "/etc/timezone" exist and if so what does it contain?
cat /etc/timezone
On our Linux box running fandev.org:
SystemV/EST5EDT
not a symbolic link
US/Eastern
katoxTue 4 Nov 2008
Europe/Prague
The initial installation (Ubuntu 8.10, intrepid) got it wrong. There was no symlink and for some reason the file contained Europe/Bratislava which is not in java timezone db (jdk6u10)
Not a symlink: -rw-r--r-- 1 root root 3519 2008-10-01 13:11 /etc/localtime
Does "/etc/timezone" exist and if so what does it contain?
No
jakbWed 11 Feb 2009
hi I get same error as reported in the initial posting.
My error:
ERROR: Cannot init current timezone
sys::ParseErr: TimeZone not found: GMT-05
My TZ:
$ date +%Z
EST
My os:
Ubuntu 8.04.1
My java:
java version "1.5.0_15"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_15-b04)
Java HotSpot(TM) Client VM (build 1.5.0_15-b04, mixed mode, sharing)
"Fix"
$ vim lib/sys.props
fan.timezone=EST
Is this the solution? It would be nice if someone could tell me what do here ...
thanks ben
brianWed 11 Feb 2009
I might still not have all my hacks correct. Can you send me what Java reports as its timezone:
java.util.TimeZone.getDefault().getID();
To work around it, you to put an Olsen timezone identifier into sys props (EST is not an unambiguous identifier):
fan.timezone=New_York
Linux support for timezones is really hosed up in Java - believe it or not, but this sites gets dozens of hits for people searching for linux/java timezone issues. Linux reports GMT offsets - those are not really timezones anybody uses because those don't take into account DST rules. So if you are using Linux and care about time you should set the timezone explicitly in your lib/sys.props.
brianWed 11 Feb 2009
I pushed another "fix" to try and handle all the various case reported here so far.
Note that the fix just maps the GMT offsets to a generic timezone which won't know about your political regions DST rules. So there is a still a fundamental problem in Java on Linux.
jakbWed 11 Feb 2009
brian> Can you send me what Java reports as its timezone:
msylvan Sun 15 Jun 2008
By default, my Fedora Linux installation comes with the TZ environment variable not set. When Fan queries the system for the current time zone (why is this needed for the Fan shell, by the way? Curious), Java (both JDK 6 / x86 from Sun and OpenJDK 1.6.0 / x64 from Fedora) returns GMT-05:00, which Fan is really unhappy about:
Setting TZ to
America/New_York
works, but should this be fixed in Fan, or in Fedora? (Apologies if this should go to the Sourceforge bugtracker instead; there is no bug filed there so I'm not sure if it's being used)Got here from the Wide Finder project, by the way. Cool language!
-- Michel
andy Sun 15 Jun 2008
Thanks Michel - we'll take a look. And yeah, we're only using SF for downloads, so this is the correct place to report bugs (eventually there will be formal bug tracking on this site).
brian Mon 16 Jun 2008
Yeap - I noticed this problem on Solaris working on WideFinder. I try to map the Java's timezone to an Olsen timezone on startup. On Windows and OS X this seems to work really well. On Unix it seems every variant does things a bit different - which is weird because one would think Unix would always use a clean Olsen tz. I've already added a fix in the code to deal with "GMT0" and "GMT+/-hh:mm". Please let me know if someone is using a variant of Linux that does something else.
But I still think there is a problem in either the OS or the JDK: GMT-5:00 is not the same as America/New_York since it doesn't come with any historical or daylight saving rules. So as a backup you can always set the timezone explicitly in "lib/sys.props".
Stephen is a Java time guru, so maybe he knows more.
msylvan Mon 16 Jun 2008
GMT-5 is definitely not EST/EDT -- and even EST/EDT is not unambiguous across different countries.
So it looks like both Linux and Solaris no longer set the TZ environment variable; the common factor seems to be the Java runtime. Looking at it using Scala reveals the oddity: Java is definitely not returning the correct time zone!
Whereas according to the Unix date tool:
kevykev Mon 29 Sep 2008
Im having a similar problem on Ubuntu 8.04; Java reports the timezone as "US/Pacific" which is not in the timezones.ftz database:
The Unix date tool returns
PDT
and my system timezone is set to "Americas/Los_Angeles" at the moment. I guess a quick fix would be to just add a "US/Pacific" timezone to the timezones.ftz database. Is there some piece of code or script that is used to generate this database?brian Mon 29 Sep 2008
The US/Pacific timezone is in the backward list which was deprecated in 1993 - so it definitely seems odd that all these Java ports to Linux are doing the wrong thing.
It might make more sense to have the Linux bash scripts pass in the tz from the OS and use that to map into the olsen database. I'll take a look.
In the meantime you can always "fix" via lib/sys.props:
brian Tue 4 Nov 2008
For those of you running Linux or Solaris I'd be interested in gathering some information.
ls -l /etc/localtime
cat /etc/timezone
On our Linux box running fandev.org:
katox Tue 4 Nov 2008
I fixed this by symlinking it:
helium Tue 4 Nov 2008
swaroopch Wed 5 Nov 2008
On Ubuntu 8.10 Intrepid:
katox Sat 22 Nov 2008
There seems to be a problem with
fromJava
method in current mercurial tip:no other failures in the test.
brian Sun 23 Nov 2008
Thanks for pointing that out - that was indeed a bug uncovered by running the test suite in another timezone. I pushed a fix to mercurial.
msylvan Mon 15 Dec 2008
On Fedora 10 (x86_64):
scala> java.util.TimeZone.getDefault().getID() res0: java.lang.String = GMT-05:00
Not a symlink: -rw-r--r-- 1 root root 3519 2008-10-01 13:11 /etc/localtime
No
jakb Wed 11 Feb 2009
hi I get same error as reported in the initial posting.
My error:
My TZ:
My os:
Ubuntu 8.04.1
My java:
"Fix"
Is this the solution? It would be nice if someone could tell me what do here ...
thanks ben
brian Wed 11 Feb 2009
I might still not have all my hacks correct. Can you send me what Java reports as its timezone:
To work around it, you to put an Olsen timezone identifier into sys props (EST is not an unambiguous identifier):
Linux support for timezones is really hosed up in Java - believe it or not, but this sites gets dozens of hits for people searching for linux/java timezone issues. Linux reports GMT offsets - those are not really timezones anybody uses because those don't take into account DST rules. So if you are using Linux and care about time you should set the timezone explicitly in your lib/sys.props.
brian Wed 11 Feb 2009
I pushed another "fix" to try and handle all the various case reported here so far.
Note that the fix just maps the GMT offsets to a generic timezone which won't know about your political regions DST rules. So there is a still a fundamental problem in Java on Linux.
jakb Wed 11 Feb 2009
brian> Can you send me what Java reports as its timezone:
brian> So if you are using Linux and care about time you should set the timezone explicitly in your lib/sys.props.
OK, that works for me
vertexclique Mon 17 Feb 2014
Update the timezone-aliases.props For example I have the same for Asia/Istanbul I added to the "Asia/" section with
Asia/Istanbul=Istanbul(what it called through jdk)
brian Mon 17 Feb 2014
Are you suggesting that we should add an alias for Asia/Istanbul? In the Olson database that is Europe/Istanbul
Mengu Tue 18 Feb 2014
Yes, it should be Europe/Istanbul not Asia/Istanbul.
alper Fri 21 Feb 2014
I think we should create a whole new one Eurosia/Istanbul ;)
What do you think Mahmut & Mengü?