net.sf.saxon.number
Class NamedTimeZone

java.lang.Object
  extended by net.sf.saxon.number.NamedTimeZone

public class NamedTimeZone
extends Object

This class attempts to identify a timezone name, given the date (including the time zone offset) and the country. The process is heuristic: sometimes there is more than one timezone that matches this information, sometimes there is none, but the class simply does its best. This is in support of the XSLT format-date() function.


Constructor Summary
NamedTimeZone()
           
 
Method Summary
static String formatTimeZoneOffset(DateTimeValue timeValue)
          Format a timezone in numeric form for example +03:00 (or Z for +00:00)
static String getOlsenTimeZoneName(DateTimeValue date, String country)
          Try to identify a timezone name corresponding to a given date (including time zone) and a given country.
static String getTimeZoneNameForDate(DateTimeValue date, String country)
          Try to identify a timezone name corresponding to a given date (including time zone) and a given country.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamedTimeZone

public NamedTimeZone()
Method Detail

getTimeZoneNameForDate

public static String getTimeZoneNameForDate(DateTimeValue date,
                                            String country)
Try to identify a timezone name corresponding to a given date (including time zone) and a given country. Note that this takes account of Java's calendar of daylight savings time changes in different countries. The returned value is the convenional short timezone name, for example PDT for Pacific Daylight Time

Parameters:
date - the dateTimeValue, including timezone
country - the two-letter ISO country code
Returns:
the short timezone name if a timezone with the given time displacement is in use in the country in question (on the appropriate date, if known). Otherwise, the formatted (numeric) timezone offset. If the dateTimeValue supplied has no timezone, return a zero-length string.

formatTimeZoneOffset

public static String formatTimeZoneOffset(DateTimeValue timeValue)
Format a timezone in numeric form for example +03:00 (or Z for +00:00)

Parameters:
timeValue - the value whose timezone is to be formatted
Returns:
the formatted timezone

getOlsenTimeZoneName

public static String getOlsenTimeZoneName(DateTimeValue date,
                                          String country)
Try to identify a timezone name corresponding to a given date (including time zone) and a given country. Note that this takes account of Java's calendar of daylight savings time changes in different countries. The returned value is the Olsen time zone name, for example "Pacific/Los_Angeles", followed by an asterisk (*) if the time is in daylight savings time in that timezone.

Parameters:
date - the dateTimeValue, including timezone
country - the two-letter ISO country code
Returns:
the Olsen timezone name if a timezone with the given time displacement is in use in the country in question (on the appropriate date, if known). In this case an asterisk is appended to the result if the date/time is in daylight savings time. Otherwise, the formatted (numeric) timezone offset. If the dateTimeValue supplied has no timezone, return a zero-length string.


Copyright (C) Michael H. Kay. All rights reserved.