码迷,mamicode.com
首页 > 编程语言 > 详细

Java 中时间处理 System.currentTimeMillis()

时间:2018-08-11 12:26:27      阅读:328      评论:0      收藏:0      [点我收藏+]

标签: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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!