java 根据类名示例化类_Java即时类| plusMillis()方法与示例
java 根据类名示例化类
即时类plusMillis()方法 (Instant Class plusMillis() method)
plusMillis() method is available in java.time package.
plusMillis()方法在java.time包中可用。
plusMillis() method is used to add the given duration in milliseconds to this Instant and return the Instant.
plusMillis()方法用于将给定的持续时间(以毫秒为单位)添加到此Instant并返回Instant。
plusMillis() 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.
plusMillis()方法是一种非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。
plusMillis() method may throw an exception at the time of performing addition.
plusMillis()方法在执行加法时可能会引发异常。
DateTimeException: This exception may throw when this Instant value reaches out of the min or max instant.
DateTimeException :当此Instant值超出最小或最大瞬时值时,可能引发此异常。
Syntax:
句法:
public Instant plusMillis(long millis_val);
Parameter(s):
参数:
long millis_val – represents the milliseconds value to add to this Instant.
long millis_val –表示要添加到此Instant的毫秒值。
Return value:
返回值:
The return type of this method is Instant, it returns the Instant that holds the value added the given milliseconds to this Instant.
此方法的返回类型为Instant ,它返回Instant,该Instant保留将给定毫秒数添加到此Instant的值。
Example:
例:
// Java program to demonstrate the example
// of plusMillis(long millis_val) method
// of Instant
import java.time.*;
public class PlusMillisOfInstant {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 add: " + millis);
System.out.println();
// Here, this method adds the given duration
// in milliseconds with this Instant ins1
// i.e. here we are adding the given 20000
// milliseconds with this ins1
Instant plus_millis = ins1.plusMillis(millis);
// Display plus_millis
System.out.println("ins1.plusMillis(millis): " + plus_millis);
// Here, this method adds the given duration
// in milliseconds with this Instant ins2
// i.e. here we are adding the given 20000
// milliseconds with this ins2
plus_millis = ins2.plusMillis(millis);
// Display plus_millis
System.out.println("ins2.plusMillis(millis): " + plus_millis);
}
}
Output
输出量
Instant ins1 and ins2:
ins1: 2006-04-03T05:10:15Z
ins2: 2020-05-27T00:07:38.429608Z
millis to add: 20000ins1.plusMillis(millis): 2006-04-03T05:10:35Z
ins2.plusMillis(millis): 2020-05-27T00:07:58.429608Z
翻译自: https://www.includehelp.com/java/instant-plusmillis-method-with-example.aspx
java 根据类名示例化类
java 根据类名示例化类_Java即时类| plusMillis()方法与示例相关推荐
- java 根据类名示例化类_Java即时类| from()方法与示例
java 根据类名示例化类 即时类from()方法 (Instant Class from() method) from() method is available in java.time pack ...
- java 根据类名示例化类_Java即时类| EpochSecond()方法的示例
java 根据类名示例化类 EpochSecond()方法的即时类 (Instant Class ofEpochSecond() method) Syntax: 句法: public static I ...
- java 根据类名示例化类_Java即时类| minusNanos()方法与示例
java 根据类名示例化类 即时类minusNanos()方法 (Instant Class minusNanos() method) minusNanos() method is available ...
- java 根据类名示例化类_Java即时类| getEpochSecond()方法与示例
java 根据类名示例化类 即时类getEpochSecond()方法 (Instant Class getEpochSecond() method) getEpochSecond() method ...
- java range类_Java即时类| range()方法与示例
java range类 即时类range()方法 (Instant Class range() method) range() method is available in java.time pac ...
- java 根据类名示例化类_Java LocalDateTime类| atOffset()方法与示例
java 根据类名示例化类 LocalDateTime类atOffset()方法 (LocalDateTime Class atOffset() method) atOffset() method i ...
- java 根据类名示例化类_Java MathContext类| 带示例的getRoundingMode()方法
java 根据类名示例化类 MathContext类的getRoundingMode()方法 (MathContext Class getRoundingMode() method) getRound ...
- java 根据类名示例化类_Java类类的requiredAssertionStatus()方法和示例
java 根据类名示例化类 类的类requiredAssertionStatus()方法 (Class class desiredAssertionStatus() method) desiredAs ...
- java 根据类名示例化类_Java LocalDateTime类| 带示例的getNano()方法
java 根据类名示例化类 LocalDateTime类getNano()方法 (LocalDateTime Class getNano() method) getNano() method is a ...
最新文章
- 对手机图标整理事件总结
- Java虚拟机5:常用JVM命令参数
- 20十年后的计算机作文600字,20年后的学校作文600字
- c语言指针在左还是右,C语言学习之指针的右左法则
- php背景图片随页面大小改变,css背景图根据屏幕大小自动缩放
- python网络爬虫系列(七)——selenium的介绍 selenium定位获取标签对象并提取数据 selenium的其它使用方法
- 金融行业 | 电子银行系统性能优化解决方案
- IT男的”幸福”生活续8
- VUE---不连接后端的登录验证规则方法
- as5.4安装gcc和g++
- Centos / Ubuntu /linux/mac JAVA 环境变量设置
- C++变量初始化问题
- 智能化趋势 v3.0:模板、虚拟与现实交互、无限画布
- 红巨星转场特效预设AE插件 Red Giant Universe 6.0.1 WIN
- 51单片机学习入门(三):串口
- Pointnet网络结构与代码解读
- 数据运营时代,如何基于AnalyticDB构建企业实时数仓?
- 华为服务器默认用户名和密码怎么修改,服务器默认用户名和密码
- 10月1日 - 10月7日,国庆
- 20155305乔磊2016-2017-2《Java程序设计》第二周学习总结
热门文章
- Linux apt命令
- mmdetection 使用笔记 01: 安装与简单的推理demo
- linux 磁盘分配 简书,linux 磁盘分区
- android preferenceactivity 源码,PreferenceActivity PreferenceScreen (3.0/API 11 以前)
- jupyter kernel_新乡联通案例分享:Jupyter开发环境配置的常用技巧
- PHP无法执行MySQL语句,解决PHP执行批量MySQL语句的问题
- lua判断字符不为空或空格_Lua判断字符串前缀是否为指定字符的3种方法
- python变量区变量保存与加载_python – Flask:使用全局变量将数据文件加载到内存中...
- violinplot如何看懂_一张图告诉你如何看懂个股大趋势
- webpack学习笔记1