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

查看所有标签

Distributed Algorithms

Distributed Algorithms

Wan Fokkink / The MIT Press / 2013-12-6 / USD 40.00

This book offers students and researchers a guide to distributed algorithms that emphasizes examples and exercises rather than the intricacies of mathematical models. It avoids mathematical argumentat......一起来看看 《Distributed Algorithms》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

SHA 加密
SHA 加密

SHA 加密工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具