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 }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-31
  • 2021-07-24
  • 2021-06-17
  • 2021-08-01
猜你喜欢
  • 2022-12-23
  • 2021-11-08
相关资源
相似解决方案