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://www.codercto.com/courses/l/12.html

查看所有标签

Probability and Computing: Randomization and Probabilistic Techn

Probability and Computing: Randomization and Probabilistic Techn

Michael Mitzenmacher、Eli Upfal / Cambridge University Press / 2017-7-3 / USD 62.23

Greatly expanded, this new edition requires only an elementary background in discrete mathematics and offers a comprehensive introduction to the role of randomization and probabilistic techniques in m......一起来看看 《Probability and Computing: Randomization and Probabilistic Techn》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器