content: package com.smart.common.util;
  
  import java.sql.Timestamp;
  import java.text.ParseException;
  import java.text.SimpleDateFormat;
  import java.util.Date;
  
  /**
   * 日期处理
   * 爪哇笔记：https://blog.52itstyle.vip
   */
  public class DateUtils {
  	
  	
  	/** 时间格式(yyyy-MM-dd) */
  	public final static String DATE_PATTERN = "yyyy-MM-dd";
  	
  	/** 时间格式(yyyy-MM-dd HH:mm:ss) */
  	public final static String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
  	
  	public static String format(Date date) {
  		return format(date, DATE_PATTERN);
  	}
  
  	public static String format(Date date, String pattern) {
  		if (date != null) {
  			SimpleDateFormat df = new SimpleDateFormat(pattern);
  			return df.format(date);
  		}
  		return null;
  	}
  	public static String format(Timestamp date, String pattern) {
  		if (date != null) {
  			SimpleDateFormat df = new SimpleDateFormat(pattern);
  			return df.format(date);
  		}
  		return null;
  	}
  	public static Date format(String str, String pattern) {
  		if (str != null) {
  			SimpleDateFormat df = new SimpleDateFormat(pattern);
  			try {
  				return df.parse(str);
  			} catch (ParseException e) {
  				e.printStackTrace();
  			}
  		}
  		return null;
  	}
  	
  	/**
  	 * 获取当前日期
  	 */
  	public static Timestamp getTimestamp() {
  		return new Timestamp(System.currentTimeMillis());
  	}
  
  	public static String getTime() {
  		return format(new Timestamp(System.currentTimeMillis()),DATE_TIME_PATTERN);
  	}
  
      public static void main(String[] args) {
          System.out.println(System.currentTimeMillis());
      }
  }
  