博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
java 根据类名示例化类_Java即时类| minusMillis()方法与示例
阅读量:2534 次
发布时间:2019-05-11

本文共 2835 字,大约阅读时间需要 9 分钟。

java 根据类名示例化类

即时类minusMillis()方法 (Instant Class minusMillis() method)

  • minusMillis() method is available in java.time package.

    minusMillis()方法在java.time包中可用。

  • minusMillis() method is used to subtract the given duration in milliseconds from this Instant and returns the Instant.

    minusMillis()方法用于从此Instant减去给定的持续时间(以毫秒为单位),并返回Instant。

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

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

  • minusMillis() method may throw an exception at the time of performing subtraction.

    minusMillis()方法在执行减法时可能会引发异常。

    ArithmeticException: This exception may throw when the calculated result value exceeds the limit.

    ArithmeticException :当计算结果值超过限制时,可能引发此异常。

Syntax:

句法:

public Instant minusMillis(long millis_val);

Parameter(s):

参数:

  • long millis_val – represents the milliseconds to be subtracted from this Instant.

    long millis_val –表示要从此Instant减去的毫秒数。

Return value:

返回值:

The return type of this method is Instant, it returns the Instant that holds the value subtracted the given milliseconds from this Instant.

此方法的返回类型为Instant ,它返回Instant,该Instant保留从Instant减去给定毫秒数的值。

Example:

例:

// Java program to demonstrate the example // of minusMillis(long millis_val) method // of Instantimport java.time.*;public class MinusMillisOfInstant {
public static void main(String args[]) {
long millis = 20000; // Instantiates two Instant Instant ins1 = Instant.parse("2006-04-03T05:10:15.00Z"); Instant ins2 = Instant.now(); // Display ins1,ins2 and millis System.out.println("Instant ins1 and ins2: "); System.out.println("ins1: " + ins1); System.out.println("ins2: " + ins2); System.out.println("millis to substract: " + millis); System.out.println(); // Here, this method subtracts the given duration // in milliseconds from this Instant ins1 // i.e. here we are subtracting the given // 20000 milliseconds from this ins1 Instant minus_millis = ins1.minusMillis(millis); // Display minus_millis System.out.println("ins1.minusMillis(millis): " + minus_millis); // Here, this method subtracts the given duration // in milliseconds from this Instant ins2 // i.e. here we are subtracting the given // 20000 milliseconds from this ins2 minus_millis = ins2.minusMillis(millis); // Display minus_millis System.out.println("ins2.minusMillis(millis): " + minus_millis); }}

Output

输出量

Instant ins1 and ins2: ins1: 2006-04-03T05:10:15Zins2: 2020-05-25T22:51:33.770318Zmillis to substract: 20000ins1.minusMillis(millis): 2006-04-03T05:09:55Zins2.minusMillis(millis): 2020-05-25T22:51:13.770318Z

翻译自:

java 根据类名示例化类

转载地址:http://ktvzd.baihongyu.com/

你可能感兴趣的文章
玉伯的一道课后题题解(关于 IEEE 754 双精度浮点型精度损失)
查看>>
《BI那点儿事》数据流转换——百分比抽样、行抽样
查看>>
哈希(1) hash的基本知识回顾
查看>>
Leetcode 6——ZigZag Conversion
查看>>
dockerfile_nginx+PHP+mongo数据库_完美搭建
查看>>
Http协议的学习
查看>>
【转】轻松记住大端小端的含义(附对大端和小端的解释)
查看>>
设计模式那点事读书笔记(3)----建造者模式
查看>>
交换机划分Vlan配置
查看>>
yum安装Elasticsearch5.x
查看>>
正则表达式
查看>>
Python模块_json & pickle模块
查看>>
Python 模块之_os模块_os是与操作系统交互的接口
查看>>
通通玩blend美工(1)——荧光Button
查看>>
[UWP]了解模板化控件(8):ItemsControl
查看>>
使用JustDecompile修改程序集
查看>>
SQLServer 分组查询相邻两条记录的时间差
查看>>
Swift语言指南(一)--语言基础之常量和变量
查看>>
关于webpack的使用
查看>>
Windows 2008 R2上配置IIS7或IIS7.5中的URLRewrite(URL重写)实例
查看>>