Java 中的 Instant parse() 方法
可以透過 Java 中 Instant 類中的 toString() 方法獲得 Instant 的字串表示形式。此方法不需要引數,並會返回 Instant 的字串表示形式。
示例如下 −
示例
import java.time.*;
public class Demo {
public static void main(String[] args) {
Instant i = Instant.now();
System.out.println("The current Instant is: " + i.toString());
}
}輸出
The current Instant is: 2019-02-13T09:01:52.484Z
現在讓我們瞭解一下上述程式。
使用 toString() 方法獲得當前 Instant 的字串表示形式。然後顯示該內容。展示此內容的程式碼片段如下 −
Instant i = Instant.now();
System.out.println("The current Instant is: " + i.toString());
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP