** 日期类 **
package cn.czl.proxy;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Hello {
public static void main(String[] args) throws ParseException {
// 将字符串转化为日期
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = sdf.parse("2000-12-16 16:52:39");
System.out.println(date);
Date date2 = new Date();
System.out.println(date2);
//获取当前毫秒数
long t1=System.currentTimeMillis();
System.out.println(t1);
//毫秒数转换为时间
Date date3=new Date();
date3.setTime(t1);
System.out.println(date3);
//时间格式化
Date date4=new Date();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
String fmDate=simpleDateFormat.format(date4);
System.err.println(fmDate);
//字符串格式时间获取毫秒数
long time = simpleDateFormat.parse(fmDate).getTime();
System.err.println(time);
}
}
Sat Dec 16 16:52:39 CST 2000
Sat Nov 07 00:57:37 CST 2020
1604681857207
Sat Nov 07 00:57:37 CST 2020
2020-11-07 00-57-37
1604681857000