import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* @author
*/
public class TimesUtil {
public static final Logger LOGGER = LoggerFactory.getLogger(TimesUtil.class);
private TimesUtil(){}
/**
* 获取当前日期时间戳,不包含时间
*
* @return
*/
public static long getCurrentDateTimesTamp() {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
String currentTime = simpleDateFormat.format(new Date());
long currentTimesTamp = 0;
try {
Date currentDate = simpleDateFormat.parse(currentTime);
currentTimesTamp = currentDate.getTime();
} catch (ParseException e) {
LOGGER.error(e.getMessage(),e);
}
return currentTimesTamp;
}
/**
* 获取当前时间,时间戳
*
* @return
*/
public static long getCurrentTimesTamp() {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String currentTime = simpleDateFormat.format(new Date());
long currentTimesTamp = 0;
try {
Date currentDate = simpleDateFormat.parse(currentTime);
currentTimesTamp = currentDate.getTime();
} catch (ParseException e) {
LOGGER.error("时间戳转换异常:" + e.toString(), e);
}
return currentTimesTamp;
}
}