Java获取当前的时间

环境:jdk7
代码如下

import java.sql.Date;
import java.text.SimpleDateFormat;

public class data {
	public static void main(String[] args) {
		SimpleDateFormat formatter= new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
		Date date = new Date(System.currentTimeMillis());
		System.out.println(formatter.format(date));
	}
}

运行结果

posted @ 2020-08-17 14:12  Rego  阅读(162)  评论(0编辑  收藏  举报