如何把calendar.getTimeInMillis()获得的毫秒时间格式化为yyyy-MM-dd样式的时间

 622人阅读 评论(0) 收藏 举报

如何把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);

posted on 2013-03-02 14:56  zhengbeibei  阅读(15634)  评论(0编辑  收藏  举报