CY的摸鱼——SimpleDateFormat类
SimpleDateFormat提供了日期和字符串的转化,实际开发中使用比较多。
字符串转Date
String day="2023-03-21 10:10:50";
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date d=df.parse(day);
Date转字符串
Date date=new Date();
SimpleDateFormat sdf=new SimleDateFormant("yyyy-MMMM-dddd");
String d=df.parse(date);
