package com.cusc.nirvana.user.rnr.fp.common.util;

import lombok.extern.slf4j.Slf4j;

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


/**
 * @author stayAnd
 * @date 2022/4/18
 */
@Slf4j
public class DateUtil {
	public static final String YYYYMMDDDOT = "yyyy.MM.dd";

	public static final String YYMM_DD_MM = "yy-MM-dd";

	public static final String FORMAT_YYYYMMDDHHMMSS = "yyyy-MM-dd HH:mm:ss";

	public static Date parseDate(String validDateStr,String pattern) {
		try {
			SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
			return simpleDateFormat.parse(validDateStr);
		} catch (Exception e) {
			log.error("parseDate has error",e);
		}
		return null;
	}

	public static String formate(Date time, String pattern) {
		try {
			SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
			return simpleDateFormat.format(time);
		} catch (Exception e) {
			log.error("parseDate has error",e);
		}
		return null;
	}
}
