Java即時類| toString()方法與示例

即時類toString()方法 (Instant Class toString() method)

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

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

  • toString() method is used to represent this Instant as a String by using the standards ISO-8601 format.

    toString()方法用于通過使用標準ISO-8601格式將此Instant表示為String。

  • toString() 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.

    toString()方法是一種非靜態方法,只能通過類對象訪問,如果嘗試使用類名稱訪問該方法,則會收到錯誤消息。

  • toString() method does not throw an exception at the time of representing this object as a string.

    在將此對象表示為字符串時, toString()方法不會引發異常。

Syntax:

句法:

    public String toString();

Parameter(s):

參數:

  • None

    沒有

Return value:

返回值:

The return type of this method is String, it represents this Instant as a String by using ISO-8601 standards format.

此方法的返回類型為String ,它通過使用ISO-8601標準格式將該Instant表示為String。

Example:

例:

// Java program to demonstrate the example 
// of String toString() method 
// of Instant
import java.time.*;
public class ToStringOfInstant {
public static void main(String args[]) {
// 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 toString()
// represents this Instant ins1 
// as a String
String to_string = ins1.toString();
// Display to_string
System.out.println("ins1.toString(): " + to_string);
// Here, this method toString()
// represents this Instant ins2 
// as a String
to_string = ins2.toString();
// Display to_string
System.out.println("ins2.toString(): " + to_string);
}
}

Output

輸出量

Instant ins1 and ins2: 
ins1: 2006-04-03T05:10:15Z
ins2: 2020-05-27T05:55:54.328647Zins1.toString(): 2006-04-03T05:10:15Z
ins2.toString(): 2020-05-27T05:55:54.328647Z

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

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/541551.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/541551.shtml
英文地址,請注明出處:http://en.pswp.cn/news/541551.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

learn opengl 中文_LearnOpenGL CN

歡迎來到OpenGL的世界歡迎來到OpenGL的世界。這個工程只是我(Joey de Vries)的一次小小的嘗試,希望能夠建立起一個完善的OpenGL教學平臺。無論你學習OpenGL是為了學業,找工作,或僅僅是因為興趣,這個網站都將能夠教會你現代(Core-p…

MYSQL5.7 日志管理

2019獨角獸企業重金招聘Python工程師標準>>> 慢查詢日志slow-query-log1 slow-query-log-filefile_name long_query_time1 #SQL執行多長時間以上會記錄到慢查詢日志,0~10s log_slow_admin_statementsOFF #在寫入慢查詢日志的語句中包含緩慢的管理語句。 …

duration java_Java Duration類| ofHours()方法與示例

duration javaDuration Class of Hours()方法 (Duration Class ofHours() method) ofHours() method is available in java.time package. ofHours()方法在java.time包中可用。 ofHours() method is used to represent the given hours in this Duration. ofHours()方法用于表示…

sumo的簡單應用_sumo快速運行簡單仿真實例詳細教程

本文旨在讓大家快速的了解sumo,并給出運行一個簡單的sumo的例子的教程,進而了解基本sumo工程的架構,使大家對該軟件產生興趣并持續學習下去,剛開始學習仿真的確枯燥,項目“跑起來”才是大家學習下去的動力,…

stl vector 函數_vector :: crbegin()函數,以及C ++ STL中的示例

stl vector 函數C vector :: crbegin()函數 (C vector::crbegin() function) vector::crbegin() is a library function of "vector" header, it is used to get the last element of a vector using const_reverse_iterator, it returns a const reverse iterator …

ReactNative學習筆記(二)Flex布局

flexDirection 決定主軸方向 column:垂直方向為主軸row:水平方向為主軸justifyContent 決定主軸元素排列方式 flex-startflex-endcenterspace-betweenspace-aroundalignItems 決定側軸元素排列方向 flex-startflex-endcenterbaselinestretch

cad導出 dxf后中文不顯示_CAD快速看圖 for Mac

CAD快速看圖 for Mac是一款非常小巧、快速、方便的DWG看圖工具,CAD快速看圖 Mac版可脫離AutoCAD最快速、最方便瀏覽DWG和DXF圖紙,支持二維或三維圖紙,支持高清、多文件和云字體,非常實用的一款CAD看圖軟件,CAD快速看圖…

scala運算符_Scala的所有符號運算符是什么意思?

scala運算符Scala的符號運算符 (Scalas symbolic operators) The symbolic operators in Scala are symbols that have a specific task that they perform when called in a Scala program. Scala library defines a lot of symbols that can be used while programming in Sc…

關于java.util.ConcurrentModificationException和remove倒數第二個元素

2019獨角獸企業重金招聘Python工程師標準>>> 首先是兩段代碼的執行結果&#xff1a; 代碼一&#xff1a; public class TestListRemove {public static void main(String[] args) {List<Integer> list new ArrayList<Integer>();list.add(1);list.add(…

linux 操作mysql 數據庫命令_Linux 操作數據庫命令

一、連接數據庫格式&#xff1a; mysql -h主機地址 -u用戶名 &#xff0d;p用戶密碼mysql -hlocalhost -uroot -p123注&#xff1a;-h,-u,-p 后面不加空格&#xff0c;進入數據庫操作后每個命令結尾都需加“&#xff1b;(分號)”二、退出MYSQL命令exit (回車)三、顯示所有數據庫…

fragment和Activity同時操作UI引起的延遲、卡頓

最近項目中遇到一個問題&#xff0c;app首頁的Activity中由若干個Fragment頁面組成&#xff0c;其中一個fragment頁面是由一個GridView和ListView組成的列表&#xff0c;如果列表中數據量過大的時候&#xff0c;在請求數據的時候點擊頁面上的其他按鈕會無響應&#xff0c;直到該…

怎么刪除mysql的壓縮包_壓縮包版mysql怎么卸載

MySQL是一個小巧玲瓏但功能強大的數據庫&#xff0c;目前十分流行。但是官網給出的安裝包有兩種格式&#xff0c;一個是msi格式&#xff0c;一個是zip格式的。那么壓縮版mysql要怎么卸載&#xff1f;下面本篇文章就來大家介紹一下&#xff0c;希望對你們有所幫助。卸載壓縮包版…

obj.val 非數組_在Ruby中使用Array.new(size,obj)創建數組

obj.val 非數組In the previous article, we have learnt how we can declare an Array class instance with the help of Array.[](*args) method? You can also notice that in the program codes written to demonstrate all those methods are having Array instances dec…

julia在mac環境變量_在Julia中找到值/變量的類型

julia在mac環境變量To find the type of a variable/value, we use the typeof() function – it accepts a parameter whose type to be found and returns its data type. 為了找到變量/值的類型&#xff0c;我們使用typeof()函數-它接受要查找其類型的參數并返回其數據類型。…

lambda表達式之進化

前言在C#我們可以自定義委托&#xff0c;但是C#為什么還要內置泛型委托呢&#xff1f;因為我們常常要使用委托&#xff0c;如果系統內置了一些你可能會用到的委托&#xff0c;那么就省去了定義委托&#xff0c;然后實例化委托的步驟&#xff0c;這樣一來既使代碼看起來簡潔而干…

mysql返回行數_如何計算MySQL查詢返回的行數?

How can I count the number of rows that a MySQL query returned?解決方案Getting total rows in a query result...You could just iterate the result and count them. You dont say what language or client library you are using, but the API does provide a mysql_nu…

md5不是對稱密碼算法_密碼學中的消息摘要算法5(MD5)

md5不是對稱密碼算法In cryptography, MD5 (Message-Digest algorithm 5) is a mainly used cryptographic hash function with a 128-bit hash value. As we use in an Internet standard (RFC 1321), MD5 has been employed or developed in a more variety of security appl…

Windows 7 SID 修改

在安裝Windows系統時會產生一個獨一無二的SID (Security ID)&#xff0c;它用來識別每一部主機&#xff0c;若在同一個區域網路內有兩部相同SID的主機&#xff0c;會出現警告訊息。一般而言&#xff0c;每次安裝時的SID不可能會發生重複&#xff0c;但若是使用TrueImage或Ghost…

discuz mysql 類_discuz7 phpMysql操作類

MySql數據庫連接類&#xff0c;大家可以看下網上老手們用的什么方法&#xff0c;大家可以直接拿來用&#xff0c;但前提是大家能熟練的掌握的基礎上&#xff0c;這樣才能有所進步。/** MySql數據庫連接類* mysql.class.php 2009.04.15 by Hackbaby*/class dbstuff {var $versio…

1 并發模型

并發系統可以采用多種并發編程模型來實現。并發模型指定了系統中的線程如何通過協作來完成分配給它們的作業。不同的并發模型采用不同的方式拆分作業&#xff0c;同時線程間的協作和交互方式也不相同。這篇并發模型教程將會較深入地介紹目前&#xff08;2015年&#xff0c;本文…