标签:for 处理 exception throws ota date() led orm not
import org.testng.annotations.Test;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class TestDate {
@Test
public void test01() throws ParseException {
Date dt= new Date();
long s=System.currentTimeMillis();
long long1= 1533954986837L;
SimpleDateFormat dtf = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat dtf1 = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss@SSS");
String sdate =dtf1.format(long1);
System.out.println(sdate);
System.out.println(dtf.format(dt));
System.out.println(dtf1.format(dt));
System.out.println(dtf1.format(dt).toString());
// Date -> String
Date date = new Date(System.currentTimeMillis());
System.out.println(dtf.format(date));
// String -> Date
String timeString = "2018-08-11 11:44:27";
Date newDate = dtf.parse(timeString);
System.out.println(newDate);
}
}
Java 中时间处理 System.currentTimeMillis()
标签:for 处理 exception throws ota date() led orm not
原文地址:https://www.cnblogs.com/qianjinyan/p/9459198.html