日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

java timezone_Java TimeZone setDefault()方法与示例

發布時間:2025/3/11 50 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java timezone_Java TimeZone setDefault()方法与示例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

java timezone

TimeZone類的setDefault()方法 (TimeZone Class setDefault() method)

  • setDefault() method is available in java.util package.

    setDefault()方法在java.util包中可用。

  • setDefault() method is used to assign the default time zone which is retrieved by using the getDefault().

    setDefault()方法用于分配使用getDefault()檢索的默認時區。

  • setDefault() method is a static method, it is accessible with the class name and if we try to access the method with the class object then we will not get an error.

    setDefault()方法是一個靜態方法,可以使用類名進行訪問,如果嘗試使用類對象訪問該方法,則不會收到錯誤。

  • setDefault() method does not throw an exception at the time of setting the default time zone.

    setDefault()方法在設置默認時區時不會引發異常。

Syntax:

句法:

public static void setDefault(TimeZone tz);

Parameter(s):

參數:

  • TimeZone tz – represents the set default time zone.

    TimeZone tz –表示設置的默認時區。

Return value:

返回值:

The return type of the method is void, it returns nothing.

該方法的返回類型為void ,不返回任何內容。

Example:

例:

// Java program to demonstrate the example // of void setDefault(TimeZone tz) // method of TimeZone import java.util.*;public class SetDefaultOfTimeZone {public static void main(String args[]) {// Instantiates TimeZone objectTimeZone tz = TimeZone.getDefault();// Display tzSystem.out.println("TimeZone.getDefault(): " + tz);// Get another time zone and set as default // time zonetz = TimeZone.getTimeZone("Africa/Asmera");// By using setDefault() method is// to set the given time zone as default// time zoneTimeZone.setDefault(tz);System.out.print("TimeZone.setDefault(tz): ");System.out.println(tz);} }

Output

輸出量

TimeZone.getDefault(): sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null] TimeZone.setDefault(tz): sun.util.calendar.ZoneInfo[id="Africa/Asmera",offset=10800000,dstSavings=0,useDaylight=false,transitions=6,lastRule=null]

翻譯自: https://www.includehelp.com/java/timezone-setdefault-method-with-example.aspx

java timezone

總結

以上是生活随笔為你收集整理的java timezone_Java TimeZone setDefault()方法与示例的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。