Joda Time Zone pattern changing in environments
I am confused about why my date time formatting output for some time zones is changing on my environments.
I have a war, I run this war as a standalone war on Jetty (using Java 1.5), this code
System.out.println(new DateTime().withZone(DateTimeZone.forID("Asia/Kolkata")).toString("zzz"));
Produces Output: IST
When I put this war 开发者_StackOverflowinto an ear, and run on WebSphere 6.1,
Output: '+5:30
'
I would desire that "IST" be shown in both places. I suspecting that it has something to do with the class loading, and how Joda finds the Time Zone definitions. If I could just be pointed at some documentation, I would be so grateful.
I am using Joda 1.6.2
Some documentation on this can be found at http://joda-time.sourceforge.net/tz_update.html - you should make sure, that existing jars in your application server do not override these timezone files.
In 2011, you could download ftp://elsie.nci.nih.gov/pub/tzdata2011h.tar.gz, and search for the terms 'Kolkata' and 'IST' in the unpacked directory. In 2017, you'd find the data via IANA (https://iana.org/time-zones and ftp://ftp.iana.org/tz — e.g. ftp://ftp.iana.org/tz/releases/tzdata2017a.tar.gz).
Then look up the existing jars in your application server, and see where you find the same filenames in them. I personally like to use my own little little 'grepJars.sh' bash script, which finds a file by filename in all jars/wars/ears in the current directory (not subdirectories!):
#!/bin/bash
searchterm=$1
handleFile()
{
f=$1
found=`jar tf "$f"|grep "$searchterm"`
if [ "$found" ]; then
echo "-----------------"
echo "$f"
echo "-----------------"
echo "$found"
fi
}
ls *.?ar|while read f; do handleFile $f; done
Then again, there are probably better search scripts/tools out there...
精彩评论