Java 实例 - 格式化时间(SimpleDateFormat)

Java 教程 · 2019-02-10 13:59:11

以下实例演示了如何使用 SimpleDateFormat 类的 format(date) 方法来格式化时间

Main.java 文件

import java.text.SimpleDateFormat; import java.util.Date; public class Main{ public static void main(String[] args){ Date date = new Date(); String strDateFormat = "yyyy-MM-dd HH:mm:ss"; SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat); System.out.println(sdf.format(date)); } }

以上代码运行输出结果为:

2015-03-27 21:13:23

点击查看所有 Java 教程 文章: https://codercto.com/courses/l/12.html

查看所有标签

AI Algorithms, Data Structures, and Idioms in Prolog, Lisp, and

AI Algorithms, Data Structures, and Idioms in Prolog, Lisp, and

George F. Luger、William A Stubblefield / Addison Wesley / 2008-09-04 / USD 22.20

This book is designed for three primary purposes. The first is as a programming language component of a general class in Artificial Intelligence. From this viewpoint, the authors see as essential that......一起来看看 《AI Algorithms, Data Structures, and Idioms in Prolog, Lisp, and 》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

SHA 加密
SHA 加密

SHA 加密工具

html转js在线工具
html转js在线工具

html转js在线工具