Java GregorianCalendar setTimeZone()方法与示例
GregorianCalendar类setTimeZone()方法 (GregorianCalendar Class setTimeZone() method)
setTimeZone() method is available in java.util package.
setTimeZone()方法在java.util包中可用。
setTimeZone() method is used to sets the time zone with the specified TimeZone(tz) for this GregorianCalendar.
setTimeZone()方法用于为此GregorianCalendar设置具有指定TimeZone(tz)的时区。
setTimeZone() method is a non-static method, so it is accessible with the class object and if we try to access the method with the class name then we will get an error.
setTimeZone()方法是一种非静态方法,因此可以通过类对象进行访问,如果尝试使用类名称访问该方法,则会收到错误消息。
setTimeZone() method does not throw an exception at the time of the set time zone.
setTimeZone()方法在设置的时区时不会引发异常。
Syntax:
句法:
public void setTimeZone(TimeZone tz);
Parameter(s):
参数:
TimeZone tz – represent the time zone to be set for this calendar.
TimeZone tz –表示要为此日历设置的时区。
Return value:
返回值:
The return type of the method is void, it returns nothing.
该方法的返回类型为void ,不返回任何内容。
Example:
例:
// Java program is to demonstrate the example of
// setTimeZone(TimeZone tz) method of GregorianCalendar
import java.util.*;
public class SetTimeZoneOfGregorianCalendar {public static void main(String[] args) {// Instantiates a GregorianCalendar object
GregorianCalendar ca = (GregorianCalendar) GregorianCalendar.getInstance();
TimeZone tmz = TimeZone.getTimeZone("GMT");
// Display current GregorianCalendar
System.out.println("ca: " + ca.getTime());
// By using setTimeZone() method isto
// set the time zone of this GregorianCalendar
ca.setTimeZone(tmz);
// By using getTimeZone() method isto
// get the time zone of this GregorianCalendar
System.out.print("ca.setTimeZone(tmz): ");
System.out.println(ca.getTimeZone().getDisplayName());
}
}
Output
输出量
ca: Sat Feb 15 13:00:55 GMT 2020
ca.setTimeZone(tmz): Greenwich Mean Time
翻译自: https://www.includehelp.com/java/gregoriancalendar-settimezone-method-with-example.aspx
Java GregorianCalendar setTimeZone()方法与示例相关推荐
- Java IOUtils.copy方法代码示例(亲测)
本文整理汇总了Java中org.apache.commons.io.IOUtils.copy方法的典型用法代码示例.如果您正苦于以下问题:Java IOUtils.copy方法的具体用法?Java I ...
- java user directory,Java ProcessBuilder directory()方法与示例
语法:public File directory (); public ProcessBuilder directory (File dir); ProcessBuilder类directory()方 ...
- Java序列化魔术方法及其示例使用
在上一篇文章中, 您需要了解有关Java序列化的所有知识 ,我们讨论了如何通过实现Java序列化来启用类的可序列化性. Serializable接口. 如果我们的类未实现Serializable接口, ...
- catalog java,Java Connection getCatalog()方法与示例
通常,目录是一个目录,其中包含有关数据集,文件或数据库的信息.而数据库目录中包含所有数据库,基本表,视图(虚拟表),同义词,值范围,索引,用户和用户组的列表. Connection接口的getCata ...
- filepermission java,Java FilePermission getActions()方法与示例
FilePermission类getActions()方法getActions()方法在java.io包中可用. getActions()方法用于检查此FilePermission和给定对象在路径名和 ...
- java方法参数Bundle,Java ResourceBundle keySet()方法及示例
ResourceBundle类keySet()方法keySet()方法在java.util包中可用. keySet()方法用于从此ResourceBundle及其超级捆绑包中获取所有现有键,以在Set ...
- java exec waitfor,Java Process waitFor()方法与示例
流程类waitFor()方法在java.lang包中提供了waitFor()方法. waitFor()方法用于使当前正在运行的线程在需要时等待,直到由该Process对象表示的进程完成其终止为止. 当 ...
- java arraylist.add(),Java ArrayList add()方法与示例
ArrayList类add()方法 语法:public boolean add(T ele); public void add(int indices, T ele);add()方法在java.uti ...
- java rollback用法,Java Connection rollBack()方法与示例
回滚操作将撤消当前事务所做的所有更改,即,如果调用Connection接口的rollBack()方法,则所有修改都将还原到最后一次提交. 您还可以通过将所需的Savepoint对象作为参数传递给此方法 ...
最新文章
- ubuntu ftp服务器搭建,绝对有效,操作简单
- jvm高并发_JVM上的高并发HTTP客户端
- 有前途的程序员的14个习惯,你有几个?
- AI 应届博士生年薪八十万,贵吗?
- 基础总结篇之七:ContentProvider之读写短消息
- 20.Mybatis之逆向工程
- Silverlight中如何获取当前xap文件的地址以及部署了当前xap的页面地址
- 完美数及寻找完美数的算法(Perfect number‘s algorithm)
- 43张图详解计算机网络,看这一篇就够了
- 在线二进制转文本字符工具
- vs2019编译的程序在win7环境上运行失败
- Mybatis批量新增
- TiDB-explain详解
- springcloudAlibaba+dubbo线程拥堵Thread pool is EXHAUSTED
- ISP各个模块功能介绍
- Java实习生常规技术面试题每日十题Java基础(四)
- 免费在线pdf转word
- java from space to space_快速定位Java 内存OOM的问题
- Python数据分析入门笔记10——简单案例练习(学生信息分析)
- 救命钱变服务费,做大病众筹的水滴筹到底靠什么赚钱?