获得系统时间

来源:互联网 发布:oracle数据库加密 编辑:程序博客网 时间:2024/06/05 13:42

 获取当前系统时间和日期并格式化输出:

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()为获取当前系统时间
}
}

0 0