其他分享
首页 > 其他分享> > springboot-时间格式工具类

springboot-时间格式工具类

作者:互联网

DateTimeUtil.java

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

/**
 * 日期时间 工具类
 */
public class DateTimeUtil {
   
   public static String getSysTime(){
      
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      
      Date date = new Date();
      String dateStr = sdf.format(date);
      
      return dateStr;
      
   }
    
   public static String getSysTimeForUpload(){

      SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");

      Date date = new Date();
      String dateStr = sdf.format(date);

      return dateStr;

   }
   // 将时间格式转化为字符串
   public static String getSysTimeForUpload(String date){

      SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");

      String dateStr = sdf.format(date);

      return dateStr;

   }
}

标签:springboot,SimpleDateFormat,Date,sdf,dateStr,date,格式,工具,String
来源: https://blog.csdn.net/qq_45958469/article/details/121629743