加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

Java 中时间处理 System.currentTimeMillis()

发布时间:2020-12-14 06:15:07 所属栏目:Java 来源:网络整理
导读: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.curren
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);    }}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读