top.doudou.common.tool.utils.FastDateFormat Maven / Gradle / Ivy
package top.doudou.common.tool.utils;
import java.text.SimpleDateFormat;
import java.util.TimeZone;
/**
* @Description
* @Author 傻男人 <[email protected]>
* @Date 2020-10-09 14:48
* @Version V1.0
*/
public class FastDateFormat {
/**
* 防止转化后时间少8小时
* @param pattern
* @return
*/
public static SimpleDateFormat createDateFormat(String pattern) {
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
TimeZone gmt = TimeZone.getTimeZone("GMT");
sdf.setTimeZone(gmt);
sdf.setLenient(true);
return sdf;
}
}