天天看點

Date Util

時間轉化工具類

  1. List item

DateUtIs

//日期轉換成字元串
public class DateUtils{
  public static String dateToString(Date date,String str){
      SimpleDateFormat sdf=new SimpleDateFormat(str);
      String format= sdf.format(date);
         return format;
}
//字元串轉換成日期

   public static Date stringToDate(String str2,String str) throws ParseException {
      SimpleDateFormat sdf=new SimpleDateFormat(str);
      Date parse =sdf.parse(str2);
         return parse;
}