com.dahuatech.icc.multiinone.utils.DateUtils Maven / Gradle / Ivy
The newest version!
package com.dahuatech.icc.multiinone.utils;
import com.dahuatech.icc.multiinone.exception.BusinessException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateUtils {
public static long getSecords(String dateStr){
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try{
Date date = dateFormat.parse(dateStr);
return date.getTime() / 1000;
}catch (Exception e){
throw new BusinessException("时间格式转换错误");
}
}
}