Java TimeZone setID() Example
TimeZone class setID() method example. This example shows you how to use setID() method.
Syntax is : public void setID(String ID)
Method sets the time zone ID. This does not change any other data in the time zone object.
Here is the code.
/**
* @(#) SetIDTimeZone.java
* A class representing use of method setID() of TimeZone
class in java.util Package.
* @Version 28-May-2008
* @author Rose India Team
*/
import java.util.*;
class SetIDTimeZone {
public static void main( String args[] ){
// Create object of TimeZone class.
TimeZone obj = TimeZone.getDefault();
// getID() method call for dafault time zone.
String id = obj.getID();
System.out.println("Id of the default time zone is : " + id);
// setID() method call.
obj.setID("Europe/Paris");
System.out.println("\n#### ID for time zone set successfully !\n");
id = obj.getID();
System.out.println("New Id of the default time zone is : " + id);
}
} |
Output of the program.
Id of the default time zone is : GMT+05:30
#### ID for time zone set successfully !
New Id of the default time zone is : Europe/Paris |
|