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.pswp.cn/news/379448.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/379448.shtml
英文地址,請注明出處:http://en.pswp.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協議…