package com.xintong.visualinspection.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {
	
	/**
	 * string date parse Date
	 * @param strDate 
	 * @return Date (Exception null)
	 */
	public static Date strParseDate(String strDate){
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss" );
		try {
			return sdf.parse(strDate);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return null;
	}
	
	public static Date strParseDate(String strDate,String format){
		SimpleDateFormat sdf = new SimpleDateFormat(format);
		try {
			return sdf.parse(strDate);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return null;
	}
	
	public static String DateFormatStr(Date date , String format){
		SimpleDateFormat sdf = new SimpleDateFormat(format);
		try{
			return sdf.format(date);
		}catch(Exception e){
			e.printStackTrace();
		}
		return "" ;
	}
	
	public static String DateFormatStr(Date date){
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		try{
			return sdf.format(date);
		}catch(Exception e){
			e.printStackTrace();
		}
		return "" ;
	}
}
