java 根据类名示例化类_Java即时类| EpochSecond()方法的示例

java 根据类名示例化类

EpochSecond()方法的即时类 (Instant Class ofEpochSecond() method)

Syntax:

句法:

    public static Instant ofEpochSecond(long sec_val);
public static Instant ofEpochSecond(long sec_val, long nanos_adjust);

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

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

  • ofEpochSecond(long sec_val) method is used to represent an instance of this Instant by using the given seconds from the java epoch standard format since 1970-01-01T00:00:00Z.

    ofEpochSecond(long sec_val)方法用于表示此Instant的实例, 方法是使用从1970-01-01T00:00:00Z开始的java epoch标准格式的给定秒数。

  • ofEpochSecond(long sec_val, long nanos_adjust) method is used to represent an instance of this Instant by using the given seconds and nano fraction of seconds from the java epoch of 1970-01-01T00:00:00Z.

    ofEpochSecond(long sec_val,long nanos_adjust)方法用于通过使用距1970-01-01T00:00:00Z的java纪元的给定秒数和秒的毫微秒数来表示此Instant的实例。

  • These methods may throw an exception at the time of representing seconds in epoch format.

    这些方法在以纪元格式表示秒时可能会引发异常。

    DateTimeException: This exception may throw when this Instant value reaches out of the min or max instant.

    DateTimeException :当此Instant值超出最小或最大瞬时值时,可能引发此异常。

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

    这些是静态方法,可通过类名进行访问,如果尝试使用类对象访问这些方法,则不会出错。

Parameter(s):

参数:

  • In the first case, "ofEpochSecond(long sec_val)",

    在第一种情况下,“ ofEpochSecond(long sec_val)”,

    • long sec_val – represents the number of seconds in value since 1970-01-01T00:00:00Z.
    • long sec_val –表示自1970-01-01T00:00:00Z以来的秒数。
  • In the second case, "ofEpochSecond(long sec_val, long nanos_adjust)",

    在第二种情况下,“ ofEpochSecond(long sec_val,long nanos_adjust)”,

    • long sec_val – Similar as defined in the first case.
    • long sec_val –与第一种情况中定义的类似。
    • long nanos_adjust – represents the adjustment when the second reaches out of range.
    • long nanos_adjust –表示秒数超出范围时的调整。

Return value:

返回值:

In both the cases, the return type of the method is Instant,

在这两种情况下,方法的返回类型均为Instant 。

  • In the first cases, it returns the Instant that represent the given seconds.

    在第一种情况下,它返回代表给定秒数的Instant。

  • In the second cases, it returns the Instant that represent the given seconds and nano fraction of seconds.

    在第二种情况下,它返回表示给定秒数和秒的毫微秒数的Instant。

Example:

例:

// Java program to demonstrate the example 
// of ofEpochSecond() method of Instant
import java.time.*;
import java.time.temporal.*;
public class OfEpochSecondOfInstant {
public static void main(String args[]) {
long epoch_sec = 25;
long nanos_adjust = 25000;
// Instantiates two Instant 
Instant ins1 = Instant.parse("2006-04-03T05:10:15.00Z");
Instant ins2 = Instant.now();
// Display ins1,ins2
System.out.println("Instant ins1 and ins2: ");
System.out.println("ins1: " + ins1);
System.out.println("ins2: " + ins2);
System.out.println();
// Here, this method represents the given second
// from the java epoch of 1970-01-01T00:00:00Z
Instant of_epoch_sec = ins1.ofEpochSecond(epoch_sec);
// Display of_epoch_sec
System.out.println("ins1.ofEpochSecond(epoch_sec): " + of_epoch_sec);
// Here, this method represents the instant by using
// seconds and nanoseconds from the java epoch
// of 1970-01-01T00:00:00Z
of_epoch_sec = ins2.ofEpochSecond(epoch_sec, nanos_adjust);
// Display of_epoch_sec
System.out.println("ins2.ofEpochSecond(epoch_sec,nanos_adjust): " + of_epoch_sec);
}
}

Output

输出量

Instant ins1 and ins2: 
ins1: 2006-04-03T05:10:15Z
ins2: 2020-05-28T07:12:35.393208Zins1.ofEpochSecond(epoch_sec): 1970-01-01T00:00:25Z
ins2.ofEpochSecond(epoch_sec,nanos_adjust): 1970-01-01T00:00:25.000025Z

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

java 根据类名示例化类

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

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

相关文章

java中Date()类型输入数据的处理

对于Date类型的数据,需要输入生日存入相应数据库中 private Date birthday;// 生日package com.pdsu.mybatis.pojo;import java.io.Serializable; import java.util.Date;public class User implements Serializable {/*** */private static final long serialVers…

(扩展)欧几里德快速幂

GCD模板 __int64 gcd(__int64 a,__int64 b) {return b0? a:gcd(b,a%b); } 欧几里德算法又称辗转相除法,用于计算两个整数a,b的最大公约数。其计算原理依赖于下面的定理: gcd函数就是用来求(a,b)的最大公约数的。 gcd函数的基本性质: gcd(a,…

汇编语言-002(.data、Equal、$、EQU 、MOV 、MOVSX、MOVZX)

1:变量相加程序 .386 .model flat,stdcall.stack 4096 ExitProcess PROTO,dwExitCode:DWORD.data firstval DWORD 20002000h secondval DWORD 11111111h thirdval DWORD 22222222h sum DWORD 0.code main PROCmov eax,firstvaladd eax,secondvaladd eax,thirdvalm…

\r与\n的区别,\r\n与\n或\r的区别(C语言/C#)

本文出处http://topic.csdn.net/t/20020718/07/882679.html 原作者:triout(笨牛) \r表示回车,\n表示换行,我们按回车按钮的时候,系统自动产生回车和换行两个字符: 回车仅仅是表示完成,把光…

通过ID查询一个用户的两种开发方法

通过ID查询一个用户的两种开发方法 数据库建表sql语句如下:https://github.com/beyondyanyu/Sayingyy/blob/master/JDBC2-数据库sql建表语句 ①,原始Dao开发: UserDao.java(接口): package com.pdsu.mybatis.dao;i…

duration java_Java Duration类| minusMinutes()方法与示例

duration java持续时间类minusMinutes()方法 (Duration Class minusMinutes() method) minusMinutes() method is available in java.time package. minusMinutes()方法在java.time包中可用。 minusMinutes() method is used to subtract the given duration in minutes from t…

Silverlight + WCF异步调用 例子

看大家好像对我的NParsing框架不是很感兴趣(写NParsing帖没人顶我),那就给大家来点“甜品”,换换口谓。来说说Silverlight方面的东西。 在Silverlight中数据通信只能用异步。有人会觉得写起来很麻烦,其实不然。也有很简…

我博客主页的搜索功能怎么不好用

用博客里面的搜索功能,“找找看”,搜索我博客里面的关键字,但是不能出现结果。但是我在别人的主页上能够搜索该人的内容,能够查询到记录,难道博客园对每个博客的信息要先排序?目前我的还不在他的搜索数据库…

小议SqlMapConfig.xml配置文件

①、mybatis-3-config.dtd 主要用于mybatis的核心配文件sqlMapConfig.xml的约束 sqlMapConfig.xml代码如下&#xff1a; <?xml version"1.0" encoding"UTF-8" ?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN&q…

ffmepg 命令提取音视频数据

原文件&#xff1a; 1&#xff1a; 原音频数据提取&#xff08;保留还是mp4的封装格式的&#xff09;&#xff1a; ffmpeg -i test_1920x1080.mp4 -acodec copy -vn audio.mp4 -vn 就是没有视频&#xff0c; -acodec copy 音频拷贝不进行任何转码 原视频数据提取&#xff0…

Java BigInteger类| modInverse()方法与示例

BigInteger类modInverse()方法 (BigInteger Class modInverse() method) modInverse() method is available in java.math package. modInverse()方法在java.math包中可用。 modInverse() method is used to calculate the mod inverse by using the inverse of (this BigInteg…

【7】jQuery学习——入门jQuery选择器之过滤选择器-可见性过滤选择器

这篇什么都不说&#xff0c;看标题就知道了&#xff0c;很简单&#xff0c;就2个选择器&#xff0c;嘿嘿 选择器描述返回$("Element:hidden")选取所有不可见的元素集合元素$("Element:visible")选取所有可见元素集合元素这篇很简单吧&#xff0c;就2个&…

Creating an undraggable TitleWindow container in Flex (转载)

The following examples show how you can create an undraggable TitleWindow container by setting the isPopUp property to false on the TitleWindow instance. <?xml version"1.0" encoding"utf-8"?><!-- http://blog.flexexamples.com/2…

汇编语言-003(LAHF_SAHF 、XCHG、FLAGS、 OFFSET、ALIGN、PTR、LENGTHOF、SIZEOF)

1&#xff1a;LAHF将EFLAGS符号寄存器低8位字节复制到AH&#xff0c;SAHF将AH复制到EFLAGS符号寄存器低8位字节 .386 .model flat,stdcall.stack 4096 ExitProcess PROTO,dwExitCode:DWORD.data saveflags BYTE ?.code main PROClahfmov saveflags ,ahmov ah,saveflagssahfIN…

Mybatis中的核心配置文件SqlMapConfig.xml详细介绍

一、properties&#xff08;属性&#xff09; 可以引用java属性文件中的配置信息如下 jdbc.properties代码如下&#xff1a; jdbc.drivercom.mysql.jdbc.Driver jdbc.urljdbc:mysql://localhost:3306/mybatis?characterEncodingutf-8 jdbc.usernameroot jdbc.passwordbeyond…

用Kotlin开发您的第一个应用程序| Android与Kotlin

In the previous article, we learned how to setup Kotlin in the android studio? Now moving to journey ahead we are going to develop our first app with Kotlin. It is the basic app, but it will let you know the structure of the program. 在上一篇文章中&#x…

数据结构与算法分析-第一章Java类(02)

编写一个名为Person的类&#xff0c;它包含分别表示人的名字与年龄的两个数据域。要求此类包含对其中任何一个数据域进行设置与获取的方法。还要求包含可进行下列测试的方法&#xff1a; 两个Person对象是否相等--即是否有相同的名称与年龄一个人是否比另一个人年长 最后&#…

asp.net对于长篇文章进行分页

对于文章篇幅比较长的&#xff0c;就必须采用分页显示。在.net中对长篇文章分页一般有2种方法&#xff0c;第一种就是先计算好一页的文字长度是多少&#xff0c;然后把文章总的长度除设置好的单页文字长度及可&#xff0c;用这方法可以减少认为进行分页的繁琐&#xff0c;但是这…

汇编语言-004(LABEL 、间接寻址、变址操作数、指针使用、TypeDef、LOOP、DWORD变量交换高位低位字)

1&#xff1a; LABEL : 为一个标号定义大小属性&#xff0c;但不分配内存与下一个变量共用内存&#xff0c;与C中UNION类似 .386 .model flat,stdcall.stack 4096 ExitProcess PROTO,dwExitCoed:DWORD.data val16 LABEL WORD val32 DWORD 12345678hLongValue LABEL DWORD val1…

(只需挨个复制粘贴命令即可部署)在Centos7下搭建文件服务器(VSFTPD)

观看北京尚学堂-百战程序员笔记一、VSFTPD简介 Linux的组件&#xff08;一款软件&#xff09;&#xff0c;安装到Linux后可以通过java代码&#xff08;FtpClient&#xff09;实现文件的上传。基于FTP协议。 由于VSFTPD是基于FTP协议&#xff0c;客户端浏览器是需要通过http协议…