All Downloads are FREE. Search and download functionalities are using the official Maven repository.

top.doudou.common.tool.utils.FastDateFormat Maven / Gradle / Ivy

There is a newer version: 1.3.2
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy