KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > java > util > TimeZone

java.util
Class TimeZone

java.lang.Object
  extended by java.util.TimeZone
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
SimpleTimeZone
See Also:
Top Examples, Source Code, Calendar, GregorianCalendar

public Object clone()
See Also:
Cloneable
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static String[] getAvailableIDs()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1175]_
By Anonymous on 2004/12/06 19:28:17  Rate
TimeZone.getAvailableIDs (  ) ; 
 


public static String[] getAvailableIDs(int rawOffset)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[303]Create a GregorianCalendar with the Pacific Daylight time zone
By Anonymous on 2003/07/08 17:43:38  Rate
public static GregorianCalendar getCalendar (  )  
  {  
     // get the supported ids for GMT-08:00  ( Pacific Standard Time )  
     String [  ]  ids = TimeZone.getAvailableIDs ( -8 * 60 * 60 * 1000 ) ; 
     // if no ids were returned, something is wrong. get out. 
     if  ( ids.length == 0 )  
         System.exit ( 0 ) ; 
  
  
     // create a Pacific Standard Time time zone 
     SimpleTimeZone pdt = new SimpleTimeZone ( -8 * 60 * 60 * 1000, ids [ 0 ]  ) ; 
  
  
     // set up rules for daylight savings time 
     pdt.setStartRule ( Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000 ) ; 
     pdt.setEndRule ( Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000 ) ; 
  
  
     // create a GregorianCalendar with the Pacific Daylight time zone 
     // and the current date and time 
     GregorianCalendar calendar = new GregorianCalendar ( pdt ) ; 
     calendar.setTime ( new Date (  )  ) ;//Current date.. 
     return calendar; 
  } 


[877]_
By Belleson on 2004/08/25 14:32:41  Rate
// A more general purpose version of Anonymous's method 
  public static GregorianCalendar getDSTCalendarInstance (  )  
   {  
      GregorianCalendar calendar = new GregorianCalendar (  ) ; 
  
  
      // Get offset of default time zone from GMT 
      int off = TimeZone.getDefault (  ) .getOffset ( 1, calendar.get ( Calendar.YEAR ) , 
                                                calendar.get ( Calendar.MONTH ) , 
                                                calendar.get ( Calendar.DATE ) , 
                                                calendar.get ( Calendar.DAY_OF_WEEK ) , 
                                                calendar.get ( Calendar.MILLISECOND )  ) ; 
      off = off / 60 / 60 / 1000; // Convert milliseconds to hours 
       
      // get supported ids for this time zone 
      String [  ]  ids = TimeZone.getAvailableIDs ( off * 60 * 60 * 1000 ) ; 
  
  
      // create a time zone for current default time 
      SimpleTimeZone daylightTime = new SimpleTimeZone ( off * 60 * 60 * 1000, ids [ 0 ]  ) ; 
  
  
      // set up rules for daylight savings time: add/subtract 1 hour at 2AM on Sundays 
      daylightTime.setStartRule ( Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000 ) ; 
      daylightTime.setEndRule ( Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000 ) ; 
  
  
      // Update calendar with new time zone and current time. 
      calendar.setTimeZone ( daylightTime ) ; 
      calendar.setTime ( new java.util.Date (  )  ) ; //Current date.. 
      return calendar; 
   }  
  
  
  
 


public static TimeZone getDefault()
See Also:
setDefault(java.util.TimeZone)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final String getDisplayName()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final String getDisplayName(boolean daylight,
                                   int style)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getDisplayName(boolean daylight,
                             int style,
                             Locale locale)
See Also:
IllegalArgumentException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final String getDisplayName(Locale locale)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int getDSTSavings()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getID()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract int getOffset(int era,
                              int year,
                              int month,
                              int day,
                              int dayOfWeek,
                              int milliseconds)
See Also:
Calendar.DST_OFFSET, Calendar.ZONE_OFFSET
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[396]_
By Anonymous on 2003/09/15 06:16:30  Rate
var off = java.util.TimeZone.getTimeZone ( PST ) .getOffset ( 1, 1900+date.getYear (  ) , date.getMonth (  ) , date.getDate (  ) , date.getDay (  ) ,date.getSeconds (  ) *1000 ) ;

public int getOffset(long date)
See Also:
Calendar.DST_OFFSET, Calendar.ZONE_OFFSET
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract int getRawOffset()
See Also:
Calendar.ZONE_OFFSET
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static TimeZone getTimeZone(String ID)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean hasSameRules(TimeZone other)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract boolean inDaylightTime(Date date)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int LONG
See Also:
SHORT
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static void setDefault(TimeZone zone)
See Also:
getDefault()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1320]Asia/Kuala_Lumpur timezone
By Anuja Piplapure on 2005/03/01 00:49:51  Rate
import java.util.TimeZone; 
 import java.sql.Timestamp; 
  
  
 public class trialTimeZone 
  {  
   public static void main  (  String args [  ]   )  
    {  
     Timestamp firstOne = new Timestamp  (  System.currentTimeMillis (  )   )  ; 
     System.out.println (  "time right now==" + firstOne  ) ; 
     TimeZone.setDefault (  TimeZone.getTimeZone ( "Asia/Kuala_Lumpur" )   ) ; 
     Timestamp secondOne = new Timestamp (  System.currentTimeMillis (  )   )  ; 
     System.out.println (  "time according to new id==" + secondOne  ) ; 
    }  
  } 


public void setID(String ID)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract void setRawOffset(int offsetMillis)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int SHORT
See Also:
LONG
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public TimeZone()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[738]America/Denver timezone
By jason { at } powerpull { dot } net on 2004/12/18 22:30:56  Rate
TimeZone myTimeZone = TimeZone.getTimeZone (  "America/Denver"  ) 

public abstract boolean useDaylightTime()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags