A few questions about TimeZone class  
Author Message
Alexandr Vishnyakov





PostPosted: Visual J# General, A few questions about TimeZone class Top

1. I've got a problem with creating default TimeZone object on my local machine:

import java.util.*;
...
TimeZone tz = TimeZone.getDefault();

this code gets the default time zone. With help of de**** i notice that tz.__id == " ". what can be a reason for this

2. I have to create a list of full time zones names with out any abbreviations. In Java it can be created with help of "String[] zones = TimeZone.getAvailableIDs();" how can i do it in J#


Visual J#46  
 
 
Lars-Inge Tonnessen





PostPosted: Visual J# General, A few questions about TimeZone class Top

Could you please show us what you are trying to do

This example will print out all the availableIDs in J# 2005/ .NET 2.0

package JTimeZone;

/**
 * Summary description for Program
 */
public class Program
{

	public Program()
	{
		System.Console.WriteLine("Start");

		String[] timeIds = java.util.TimeZone.getAvailableIDs();
		for (int counter = 0; counter < timeIds.length; counter++)
			System.Console.WriteLine(" ->" + timeIds[counter].toString());

		System.Console.WriteLine("Stop");
		System.Console.ReadKey();

	}

	public static void main(String[] args)
	{
		new Program();
	}
}
 
Best regards,
Lars-Inge Tonnessen
 

 
 
Alexandr V





PostPosted: Visual J# General, A few questions about TimeZone class Top

>Could you please show us what you are trying to do

I'm trying to get a list of time zone names. Your sample works greate:

->GMT
->UTC
->ECT
->EET
->ART ...

, but I need to get a list of full names ( Africa/Abidjan, Africa/Accra, Africa/Addis_Ababa, etc. ). How can I get it

I'm working with .NET Framework 1.1.


 
 
Lars-Inge Tonnessen





PostPosted: Visual J# General, A few questions about TimeZone class Top

I don't think all cities in the world are included in the .NET timezone like that. You probably have to implement this your self.


 
 
Alexandr V





PostPosted: Visual J# General, A few questions about TimeZone class Top

Thanks. Already implemented.


 
 
Alexandr Vishnyakov





PostPosted: Visual J# General, A few questions about TimeZone class Top

I still have a problem with getting name of the current time zone on .NET 1.1...

"1. I've got a problem with creating default TimeZone object on my local machine:

import java.util.*;
...
TimeZone tz = TimeZone.getDefault();

this code gets the default time zone. With help of de**** i notice that tz.__id == " ". what can be a reason for this "

Can you offer any solution or workaround


 
 
Lars-Inge Tonnessen





PostPosted: Visual J# General, A few questions about TimeZone class Top

This code:

System.out.println("Local zone :" + java.util.TimeZone.getDefault().getID());

gives me:

Local zone :ECT

(I'm in central european time)

Could you please reformulate your question, I don't understand it. Or please show me a code example reproducing your issue