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

查看所有标签

Thirty-three Miniatures

Thirty-three Miniatures

Jiří Matoušek / American Mathematical Socity / 2010-6-18 / USD 24.60

This volume contains a collection of clever mathematical applications of linear algebra, mainly in combinatorics, geometry, and algorithms. Each chapter covers a single main result with motivation and......一起来看看 《Thirty-three Miniatures》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试