Date date=new Date();
System.out.println(date.getTime()); //获取当前时间戳
Long timeLong=1418438884773L;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
String sd = sdf.format(new Date(timeLong)); //把时间戳转为日期
System.out.println(sd);
System.out.println(date.getTime()); //获取当前时间戳
Long timeLong=1418438884773L;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
String sd = sdf.format(new Date(timeLong)); //把时间戳转为日期
System.out.println(sd);
本文介绍如何使用Java将时间戳转换为指定格式的日期,并展示了一个简单的示例代码。
2071

被折叠的 条评论
为什么被折叠?



