如何把calendar.getTimeInMillis()获得的毫秒时间,已经写入数据库了而且转化为了字符串型例如:1229073608937样式的时间格式化为yyyy-MM-dd样式的时间?
一、
long time = 1229073608937L;
Date date = new Date(time);
java.text.SimpleDateFormat f = new java.text.SimpleDateFormat("yyyy-MM-dd");
String timestring = f.format(date);
二、
String str = String.format("%tF %<tT", 1229159619623L);
本文介绍如何将数据库中存储的毫秒时间(如1229073608937)转换为易于阅读的日期格式(如yyyy-MM-dd)。提供了两种方法实现这一目标:一种是使用Java的SimpleDateFormat类;另一种是利用String.format方法。
1471

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



