System.currentTimeMillis()获得的时间格式怎样转化成人们可接受的格式?
来源:百度知道 编辑:UC知道 时间:2024/09/24 20:29:22
或者其他可以获得系统当前时间的办法也可以。但是格式要容易接受的。
import java.util.Date;
Date date = new Date(System.currentTimeMillis());
或者
Date date = new Date();
都行
Calendar rightNow = Calendar.getInstance();
rightNow.setTimeInMillis(System.currentTimeMillis());//这里没必要
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
String now = format.format(rightNow);
String time = DateFormat.getInstance().format(new Date());
System.out.println(time);