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.mzph.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;本文…