DateDealUtils.java
1.03 KB
package com.qgutech.qgyun.apaas.sync.utils;
import com.qgutech.qgyun.apaas.sync.base.BoErrorCode;
import com.qgutech.qgyun.apaas.sync.base.BoException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateDealUtils {
/**
* 解析年份开始时间
*/
public static Date parseYearStartTime(String year) {
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return sdf.parse(year + "-01-01 00:00:00");
} catch (ParseException e) {
throw new BoException(BoErrorCode.PARAM_ERROR, "年份格式错误");
}
}
/**
* 解析年份结束时间
*/
public static Date parseYearEndTime(String year) {
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return sdf.parse(year + "-12-31 23:59:59");
} catch (ParseException e) {
throw new BoException(BoErrorCode.PARAM_ERROR, "年份格式错误");
}
}
}