ElementUI组件的传过来的时间值。
如果你没有加上 value-format=“yy-MM-dd”,值为20220314T16:00:00.000Z ,后端接受了一个国际的时间格式,加上之后会是这种时间格式。
<!-- 这里可以规定时间的格式类型 -->
<el-col :span="6">
<el-form-item label="结案日期">
<el-date-picker
v-model="submienddte"
value-format="yyyy-MM-dd"
type="date"
placeholder="选择日期"
>
</el-date-picker>
后端的java转换类:
/**
* 日期转为Integer类型
* @author
*/
public class DateChangeIntegerUtil {
/**
* Date类型转Integer,为空时返回 0
* @param parDate
* @return
*/
public static Integer convens(Date parDate){
if(null == parDate){
return 0;
}
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
String tmpDate = dateFormat.format(parDate);
Integer resDate = Integer.valueOf(tmpDate);
return resDate;
}
/**
* Integer 类型转Date 类型,为空时返回 null
* @param parDate
* @return
*/
public static Date parseDate(Integer parDate){
if(null == parDate){
return null;
}
try {
return new SimpleDateFormat("yyyyMMdd").parse(String.valueOf(parDate));
}catch (Exception e){
return null;
}
}
/**
* 字符串日期格式转Integer
*
* @param strDate
* @return
*/
public static Integer strParseInt(String strDate){
if(StringUtils.isBlank(strDate)){
return 0;
}
Integer resDate = Integer.valueOf(strDate.replace("-",""));
return resDate;
}
}