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