Java SimpleTimeZone setStartRule()方法与示例

SimpleTimeZone类setStartRule()方法 (SimpleTimeZone Class setStartRule() method)

Syntax:

句法:

    public void setStartRule(int st_mm, int st_dd, int st_time);
public void setStartRule(int st_mm, int st_dd, int st_dow, int st_time);
public void setStartRule(int st_mm, int st_dd,int st_dow, int st_time, boolean status);

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

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

  • setStartRule(int st_mm, int st_dd, int st_time) method is used to set the start rule of DST(Daylight Savings Time) to the given fixed date (dd) in a month.

    setStartRule(int st_mm,int st_dd,int st_time)方法用于将DST(夏令时)的开始规则设置为一个月中的给定固定日期(dd)。

  • setStartRule(int st_mm, int st_dd,int st_dow, int st_time) method is used to set the start rule of DST(Daylight Savings Time).

    setStartRule(int st_mm,int st_dd,int st_dow,int st_time)方法用于设置DST(夏令时)的开始规则。

  • setStartRule(int st_mm, int st_dd, int st_dow, int st_time, boolean status) method is used to set the start rule of DST(Daylight Savings Time) to the earlier weekday (dow) or after the given date (dd) in a month.

    setStartRule(int st_mm,int st_dd,int st_dow,int st_time,boolean status)方法用于将DST(夏时制)的开始规则设置为较早的工作日(dow)或一个月中给定的日期(dd)之后。

  • These methods may throw an exception at the time of setting start rule.

    这些方法在设置开始规则时可能会引发异常。

    IllegalArgumentException: This exception may throw when any one of the parameters is not in a range.

    IllegalArgumentException :当任何一个参数不在范围内时,可能引发此异常。

  • These are non-static methods and it is accessible with the class object only and if we try to access these methods with the class name then we will get an error.

    这些是非静态方法,只能通过类对象访问,如果尝试使用类名称访问这些方法,则会收到错误消息。

Parameter(s):

参数:

  • In the first case, setStartRule(int st_mm, int st_dd, int st_time)

    在第一种情况下, setStartRule(int st_mm,int st_dd,int st_time)

    • int st_mm – represents the DST starting month.
    • int st_mm –表示夏令时开始的月份。
    • int st_dd – represents the DST starting day of month.
    • int st_dd –表示夏令时开始的月份。
    • int st_time – represents the DST starting time.
    • int st_time –表示DST的开始时间。
  • In the second case, setStartRule(int st_mm, int st_dd, int st_dow, int st_time),

    在第二种情况下, setStartRule(int st_mm,int st_dd,int st_dow,int st_time)

    • int st_mm – represents the DST starting month.
    • int st_mm –表示夏令时开始的月份。
    • int st_dd – represents the DST starting day of month.
    • int st_dd –表示夏令时开始的月份。
    • int st_dow – represents the DST starting day of week.
    • int st_dow –表示夏令时开始的星期几。
    • int st_time – represents the DST starting time.
    • int st_time –表示DST的开始时间。
  • In the second case, setStartRule(int st_mm, int st_dd,int st_dow, int st_time, boolean status),

    在第二种情况下, setStartRule(int st_mm,int st_dd,int st_dow,int st_time,布尔状态)

    • int st_mm – represents the DST starting month.
    • int st_mm –表示夏令时开始的月份。
    • int st_dd – represents the DST starting day of month.
    • int st_dd –表示夏令时开始的月份。
    • int st_dow – represents the DST starting day of week.
    • int st_dow –表示夏令时开始的星期几。
    • int st_time – represents the DST starting time.
    • int st_time –表示DST的开始时间。
    • boolean status – sets to true then this rule selects first st_dow on or after st_dd otherwise this rule selects last st_dow on or before st_dd.
    • 布尔状态 –设置为true,然后此规则在st_dd或之后选择第一个st_dow,否则,在st_dd或之前选择最后一个st_dow。

Return value:

返回值:

In all cases, the return type of the method is void – It returns nothing.

在所有情况下,该方法的返回类型均为空 –它不返回任何内容。

Example:

例:

// Java program to demonstrate the example 
// of setStartRule() method of SimpleTimeZone
import java.util.*;
public class SetStartRuleOfSimpleTimeZone {
public static void main(String args[]) {
// Instantiates SimpleTimeZone object
SimpleTimeZone s_tz1 = new SimpleTimeZone(360, "FRANCE");
SimpleTimeZone s_tz2 = new SimpleTimeZone(760, "JAPAN");
SimpleTimeZone s_tz3 = new SimpleTimeZone(39800000, "US",
Calendar.APRIL, 6, -Calendar.MONDAY, 7200000, Calendar.OCTOBER, -1,
Calendar.MONDAY, 7200000, 3600000);
// By using setStartRule(yy,mm,dd) method is used to
// set the DST start rule to a constant date
s_tz1.setStartRule(Calendar.JUNE, Calendar.MONDAY, 3800000);
// By using setStartRule(yy,mm,dow,dd) method is used to
// set the DST start rule to a weekday before
// or after the given date
s_tz2.setStartRule(Calendar.JUNE, Calendar.MONDAY, 2, 3800000, false);
// By using setStartRule(yy,mm,dow,dd,boolean) method is used to
// set the DST start rule 
s_tz3.setStartRule(Calendar.JUNE, Calendar.MONDAY, 2, 3800000);
// Display SimpleTimeZone
System.out.print("s_tz1.setStartRule(Calendar.JUNE, Calendar.MONDAY,3800000): ");
System.out.println(s_tz1);
System.out.print("s_tz2.setStartRule(Calendar.JUNE, Calendar.MONDAY,3800000,false): ");
System.out.println(s_tz1);
System.out.print("s_tz3.setStartRule(Calendar.JUNE, Calendar.MONDAY,2,3800000): ");
System.out.println(s_tz1);
}
}

Output

输出量

s_tz1.setStartRule(Calendar.JUNE, Calendar.MONDAY,3800000): java.util.SimpleTimeZone[id=FRANCE,offset=360,dstSavings=3600000,useDaylight=false,startYear=0,startMode=1,startMonth=5,startDay=2,startDayOfWeek=0,startTime=3800000,startTimeMode=0,endMode=0,endMonth=0,endDay=0,endDayOfWeek=0,endTime=0,endTimeMode=0]
s_tz2.setStartRule(Calendar.JUNE, Calendar.MONDAY,3800000,false): java.util.SimpleTimeZone[id=FRANCE,offset=360,dstSavings=3600000,useDaylight=false,startYear=0,startMode=1,startMonth=5,startDay=2,startDayOfWeek=0,startTime=3800000,startTimeMode=0,endMode=0,endMonth=0,endDay=0,endDayOfWeek=0,endTime=0,endTimeMode=0]
s_tz3.setStartRule(Calendar.JUNE, Calendar.MONDAY,2,3800000): java.util.SimpleTimeZone[id=FRANCE,offset=360,dstSavings=3600000,useDaylight=false,startYear=0,startMode=1,startMonth=5,startDay=2,startDayOfWeek=0,startTime=3800000,startTimeMode=0,endMode=0,endMonth=0,endDay=0,endDayOfWeek=0,endTime=0,endTimeMode=0]

翻译自: https://www.includehelp.com/java/simpletimezone-setstartrule-method-with-example.aspx

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/545409.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

实战:Redis 性能优化方案

Redis 是基于单线程模型实现的,也就是 Redis 是使用一个线程来处理所有的客户端请求的,尽管 Redis 使用了非阻塞式 IO,并且对各种命令都做了优化(大部分命令操作时间复杂度都是 O(1)),但由于 Redis 是单线程执行的特点,因此它对性能的要求更加苛刻,本文我们将通过一些优…

Python正则表达式指南上半部

本文介绍了Python对于正则表达式的支持,包括正则表达式基础以及Python正则表达式标准库的完整介绍及使用示例。本文的内容不包括如何编写高效的正则表达式、如何优化正则表达式,这些主题请查看其他教程。注意:本文基于Python2.4完成&#xff…

算法复习第三章分治法

算法复习第三章分治法循环日程表最近点对快速排序: 循环日程表 最近点对

Oracle 的 char number varchar2 效率测试

自己在建表的时候,用到了编号的这个字段, 主要问题是要用java连接数据库,所以要有pojo类, 就像 编号 这种字段,int 不够,long 转起来麻烦,还容易出错。 突然想看看char可不可以,所…

实战:Redis 慢查询

Redis 慢查询作用和 MySQL 慢查询作用类似,都是为我们查询出不合理的执行命令,然后让开发人员和运维人员一起来规避这些耗时的命令,从而让服务器更加高效和健康的运行。对于单线程的 Redis 来说,不合理的使用更是致命的,因此掌握 Redis 慢查询技能对我们来说非常的关键。 …

Java SecurityManager checkAccess()方法与示例

Syntax: 句法: public void checkAccess (Thread th);public void checkAccess (ThreadGroup tg);SecurityManager类的checkAccess()方法 (SecurityManager Class checkAccess() method) checkAccess(Thread th) method is called for the current security manage…

算法复习第四章动态规划

算法复习第四章动态规划动态规划TSP问题0-1bag动态规划 TSP问题 0-1bag 最长公共子序列不考:

4. 星际争霸之php设计模式--工厂方法模式

题记本php设计模式专辑来源于博客(jymoz.com),现在已经访问不了了,这一系列文章是我找了很久才找到完整的,感谢作者jymoz的辛苦付出哦! 本文地址:http://www.cnblogs.com/davidhhuan/p/4248177.html PHP手册上提到的工…

Oracle 建立序列以及触发器的建立

笔记系列 序列:序列的创建方法,以及插入数据时的使用; --序列的创建 create sequence sq increment by 1 start with 1 maxvalue 10 minvalue 1 cycle cache 5--一般(一个序列可以用在多张表,但是一般情况下,一张表对应…

实战:Redis 性能测试

为什么需要性能测试? 性能测试的使用场景有很多,例如以下几个: 技术选型,比如测试 Memcached 和 Redis;对比单机 Redis 和集群 Redis 的吞吐量;评估不同类型的存储性能,例如集合和有序集合;对比开启持久化和关闭持久化的吞吐量;对比调优和未调优的吞吐量;对比不同 R…

操作系统Ubuntu(实验三四)

实验三四3._实验三:Linux进程/线程的异步并发执行3.1_fork()函数创建子进程3.2_创建线程pthread_create();4._实验四:使用信号量进行互斥与同步4.1_信号量初使用(1)信号量简单介绍(2)信号量以及P、V操作的使…

Java RandomAccessFile writeShort()方法与示例

RandomAccessFile类writeShort()方法 (RandomAccessFile Class writeShort() method) writeShort() method is available in java.io package. writeShort()方法在java.io包中可用。 writeShort() method is used to write the short value to the file as 2 bytes directly wi…

js中cookie的使用详细分析

cookie概述 cookie 是浏览器提供的一种机制,它将document 对象的cookie属性提供给JavaScript。可以由JavaScript对其进行控制,而并不是JavaScript本身的性质。cookie是 存于用户硬盘的一个文件,这个文件通常对应于一个域名,当浏览…

实战:Redis哨兵模式(上)

上一篇我们讲了主从复制模式,它是属于 Redis 多机运行的基础,但这种模式本身存在一个致命的问题,当主节点奔溃之后,需要人工干预才能恢复 Redis 的正常使用。 例如,我们有 3 台服务器做了主从复制,一个主服务器 A 和两个从服务器 B、C,当 A 发生故障之后,需要人工把 B…

Oracle plsql 打包

--打包 --创建包 --步骤: --1、声明(创建包头) --2、创建数据对象(创建包体)--1、 create or replace package myPack asv_bookCount integer;procedure p_back(v_stuid borrow.stuid%type,v_bid borrow.bid%type);fun…

计算机网络(第四章网络层)

第四章网络层4.1_网络层提供的两种服务(1)虚电路服务(2)数据报服务4.2_网络协议4.2.1_虚拟互连网络4.2.2_分类的IP地址(1)分类IP地址三种分类方法IP 地址的一些重要特点4.2.3_IP地址与硬件地址4.2.4_地址解…

Java ObjectInputStream readShort()方法(带示例)

ObjectInputStream类readShort()方法 (ObjectInputStream Class readShort() method) readShort() method is available in java.io package. readShort()方法在java.io包中可用。 readShort() method is used to read 2 bytes of short value from this ObjectInputStream. re…

实战:Redis 主从同步

主从同步(主从复制)是 Redis 高可用服务的基石,也是多机运行中最基础的一个。我们把主要存储数据的节点叫做主节点 (master),把其他通过复制主节点数据的副本节点叫做从节点 (slave),如下图所示: 在 Redis 中一个主节点可以拥有多个从节点,一个从节点也可以是其他服务…

Oracle view 小结片段

以前下载了一个关于Oracle 视图的pdf,水平有限,没看懂多少。 版本信息: select * from v$version; 数据库信息: select name, created, log_mode from v$database; 基本的许可信息 select * from v$license; 数据库中已安装的…

idea连接sqlserver及数据库操作

idea连接sqlserver及操作一、在连接过程中遇到的问题:(1)数据库登录失败(2)登录成功之后数据库端口号怎么查看二、代码连接数据库①加载驱动和连接数据库三、数据库操作连接详解链接 总体流程链接 操作实例链接 一、…