api/java/src/main/java/com/gudusoft/grabit/DateUtil.java
<reponame>orgTestCodacy11KRepos110MB/repo-9480-sqlflow_public<filename>api/java/src/main/java/com/gudusoft/grabit/DateUtil.javapackage com.gudusoft.grabit;

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

public class DateUtil {
    public DateUtil() {
    }

    public static String format(Date date) {
        return format(date, "yyyyMMdd");
    }

    public static String format(Date date, String pattern) {
        if (date != null) {
            SimpleDateFormat df = new SimpleDateFormat(pattern);
            return df.format(date);
        } else {
            return null;
        }
    }

    public static String timeStamp2Date(Long seconds) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        return sdf.format(new Date(seconds));
    }

}
