获取当前日期和时间并格式输出

来源:互联网 发布:reflower for mac 编辑:程序博客网 时间:2024/05/22 05:16

import java.util.Date;
import java.text.SimpleDateFormat;

public class NowString {    public static void main(String[] args) {        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 设置日期格式        System.out.println(df.format(new Date()));// new Date()为获取当前系统时间    }}
原创粉丝点击