package com.itheima.日期;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class date {
public static void main(String[] args) throws ParseException {
Date d=new Date();
System.out.println(d);
long time=d.getTime();
System.out.println(time);
SimpleDateFormat sdf=new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss EEE a");
String s=sdf.format(d);
System.out.println(s);
//把字符串时间解析成日期对象
String datestr="2022-12-12 12:12:11";
SimpleDateFormat a=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(a.parse(datestr));
}
}
标签:12,System,SimpleDateFormat,println,API,Date,out From: https://www.cnblogs.com/pengsuoqun123/p/18117855