您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Java 实例 - 时间戳转换成时间

2024/3/31 7:06:34发布14次查看
以下实例演示了如何使用 simpledateformat 类的 format() 方法将时间戳转换成时间:
/* author by w3cschool.cc 文件名:main.java */import java.text.simpledateformat;import java.util.date;public class main{ public static void main(string[] args){ long timestamp = system.currenttimemillis(); //获取当前时间戳 simpledateformat sdf=new simpledateformat("yyyy-mm-dd"); string sd = sdf.format(new date(long.parselong(string.valueof(timestamp)))); // 时间戳转换成时间 system.out.println(sd); }}
以上代码运行输出结果为:
2015-03-28
以上就是java 实例 - 时间戳转换成时间的内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product