【笔记——java时间格式化】java中的时间格式化工具

 1     /**
 2      * 格式化日期为 年-月-日
 3      * @param time
 4      * @return
 5      */
 6     public static String formatDate(Date time){
 7         Formatter formatter = new Formatter();
 8         formatter.format("%tF %tT", time,time);
 9         String ti = formatter.toString();
10         formatter.close();
11         return ti;
12     }
13     
14     
15     public static String formatShortDate(Date time){
16         Formatter formatter = new Formatter();
17         formatter.format("%tF", time);
18         String ti = formatter.toString();
19         formatter.close();
20         return ti;
21     }

 

posted @ 2014-12-14 17:04  cirno_9  阅读(128)  评论(0)    收藏  举报