package com.huazheng.project.greenplum.utils;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Date;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;

public class SomeUtils {

	public static String getErrorInfoFromException(Exception e) {
		try {
			StringWriter sw = new StringWriter();
			PrintWriter pw = new PrintWriter(sw);
			e.printStackTrace(pw);
			return "\r\n" + sw.toString() + "\r\n";
		} catch (Exception e2) {
			return "bad getErrorInfoFromException";
		}
	}
	
	public static Date caDate(String datestr) {
		try {
			if (datestr == null || datestr.equals("00000000") || StrUtil.isBlank(datestr)) {
				return null;
			} else {
				Date date = DateUtil.parse(datestr, "yyyyMMdd");
				return date;
			}
		} catch (Exception e) {
			return null;
		}
	}
	
}
