Name: joT67522 Date: 10/24/97
The attached applet exhibits a long time zone name
which is different from the name in the TimeZone.java
SimpleTimeZone table comments. (The Comment column was
added by hand.)
Ordinal ID rawOffset(hh:mm) dstOffset(hh:mm) long name Comment
19 AST -09:00 -09:00 Atlantic Standard Time Alaska Standard Time
/*
* @(#)TZApplet.java 1.0 9/19/1997
*
* Copyright (c) 1997 by Sun Microsystems, Inc. All Rights Reserved
*
* Date Author Change
* 9/19/97 Wally Wedel Created
*
*/
import java.applet.*;
import java.awt.Color;
import java.awt.GridLayout;
import java.text.SimpleDateFormat;
import java.text.FieldPosition;
import java.util.Calendar;
import java.util.Date;
import java.util.SimpleTimeZone;
import java.util.TimeZone;
// import jclass.bwt.JCMultiColumnList;
/**
* TZApplet is a class to test JDK 1.1 time zone support.
*
* @author Wally Wedel
*
*/
public class TZApplet extends Applet {
int MILLISPERHOUR = 60*60*1000;
/**
* Construct myself with default values.
**/
public TZApplet() {
super();
}
/**
* A few simple tests.
**/
public void init() {
String[] cols = {"Ordinal","ID","GMTOffset", "DSTOffset","Name"};
/*
* Instantiate a TimeZone so we can get the ids.
*/
TimeZone tz = new SimpleTimeZone(-7*MILLISPERHOUR,"PNT");
/*
* Computational variables.
*/
int offset, rawOffset, minutesOffset, hours, minutes, rHours, rMinutes;
/*
* Instantiate a SimpleDateFormat set up to produce a full time zone name.
*/
SimpleDateFormat sdf = new SimpleDateFormat("zzzz");
/*
* A String array for the time zone ids.
*/
String[] ids = tz.getAvailableIDs();
/*
* Instantiate a Date.
*/
Date aDay = new Date(1997,1,1);
/*
* How many ids do we have?
*/
System.out.println(" Time Zone IDs size: " + ids.length);
/*
* Column headings (sort of)
*/
System.out.println("Ordinal ID rawOffset(hh:mm) dstOffset(hh:mm) name");
setLayout(new GridLayout(1,1));
setBackground(Color.lightGray);
// JCMultiColumnList mcl = new JCMultiColumnList();
/*
* Loop through the tzs.
*/
for (int i = 0; i < ids.length; i++) {
// System.out.println(i + " " + ids[i]);
TimeZone ttz = tz.getTimeZone(ids[i]);
rawOffset = ttz.getRawOffset();
offset = getDSTOffset(ttz, aDay);
char sign = '+';
if (offset < 0) {
sign = '-';
offset = -offset;
rawOffset = -rawOffset;
}
// System.out.println(i + " " + ids[i] + " offset " + offset);
rHours = rawOffset/3600000;
hours = offset/3600000;
rMinutes = (rawOffset%3600000)/60000;
minutes = (offset%3600000)/60000;
String dstOffset = "" + sign + (hours < 10 ? "0" : "") +
hours + ':' + (minutes < 10 ? "0" : "") + minutes;
String gmtOffset = "" + sign + (rHours < 10 ? "0" : "") +
rHours + ':' + (rMinutes < 10 ? "0" : "") + rMinutes;
// System.out.println(i + " " + ids[i] + " offset " + hours + ":" + minutes);
sdf.setTimeZone(ttz);
/*
* Format the output.
*/
StringBuffer tzS = new StringBuffer();
sdf.format(aDay,tzS, new FieldPosition(0));
/*
* Show our result.
*/
System.out.println(i + " " + ids[i] + " " + gmtOffset + " " + dstOffset + " " + tzS);
String row = (new Integer(i)).toString() + "|" + ids[i] + "|" + gmtOffset + "|" + dstOffset + "|" + tzS.toString();
// mcl.addItem(row,'|');
}
// mcl.setColumnButtons(cols);
// add(mcl);
}
public void start() {
}
public void stop() {
}
public void destroy() {
}
public int getDSTOffset(TimeZone tz, Date date) {
/*
* Instantiate a Calendar so we can get DST offset.
*/
Calendar cal = Calendar.getInstance();
cal.setTimeZone(tz);
cal.setTime(date);
return cal.get(Calendar.ZONE_OFFSET) +
cal.get(Calendar.DST_OFFSET);
}
public static void main(String args[]) {
Applet a = new TZApplet();
a.init();
}
}
The proper acronym per the NIH tables is AKST but that's more than three
letters! Here are the pertinent comments from the NIH northamerica data:
# From Bob Devine (1988-01-28):
# ...Alaska (and Hawaii) had the timezone names changed in 1967.
# old new
# Pacific Standard Time(PST) -same-
# Yukon Standard Time(YST) -same-
# Central Alaska S.T. (CAT) Alaska-Hawaii St[an]dard Time (AHST)
# Nome Standard Time (NT) Bering Standard Time (BST)
#
# ...Alaska's timezone lines were redrawn in 1983 to give only 2 tz.
# The YST zone now covers nearly all of the state, AHST just part
# of the Aleutian islands. No DST.
# From Paul Eggert (1995-12-19):
# The tables below use `NST', not `NT', for Nome Standard Time.
# I invented `CAWT' for Central Alaska War Time.
# From U. S. Naval Observatory (1989-01-19):
# USA EASTERN 5 H BEHIND UTC NEW YORK, WASHINGTON
# USA EASTERN 4 H BEHIND UTC APR 3 - OCT 30
# USA CENTRAL 6 H BEHIND UTC CHICAGO, HOUSTON
# USA CENTRAL 5 H BEHIND UTC APR 3 - OCT 30
# USA MOUNTAIN 7 H BEHIND UTC DENVER
# USA MOUNTAIN 6 H BEHIND UTC APR 3 - OCT 30
# USA PACIFIC 8 H BEHIND UTC L.A., SAN FRANCISCO
# USA PACIFIC 7 H BEHIND UTC APR 3 - OCT 30
# USA ALASKA STD 9 H BEHIND UTC MOST OF ALASKA (AKST)
# USA ALASKA STD 8 H BEHIND UTC APR 3 - OCT 30 (AKDT)
# USA ALEUTIAN 10 H BEHIND UTC ISLANDS WEST OF 170W
# USA - " - 9 H BEHIND UTC APR 3 - OCT 30
# USA HAWAII 10 H BEHIND UTC
# USA BERING 11 H BEHIND UTC SAMOA, MIDWAY
# From Arthur David Olson (1989-01-21):
# The above dates are for 1988.
# Note the "AKST" and "AKDT" abbreviations, the claim that there's
# no DST in Samoa, and the claim that there is DST in Alaska and the
# Aleutians.
======================================================================
- duplicates
-
JDK-4028006 API: Cannot create Atlantic Standard Time zone
- Closed