1 package util;
 2 
 3 import java.text.SimpleDateFormat;
 4 import java.util.Date;
 5 
 6 public class DateUtil {
 7 
 8     public static String formatDate(Date date,String format) {
 9         String result = "";
10         SimpleDateFormat sdf = new SimpleDateFormat(format);
11         if(date!=null){
12             result = sdf.format(date);
13         }
14         return result;
15     }
16     
17     public static Date formatString(String str,String format) throws Exception{
18         SimpleDateFormat sdf=new SimpleDateFormat(format);
19         return sdf.parse(str);
20     }
21 }

 

posted on 2016-08-09 00:13  Sharpest  阅读(195)  评论(0编辑  收藏  举报