java实体类中日期类型怎么给默认值?


你可以引入一个间接层来实现你的功能..
public interface ApplicationEnvironment{
public Date currentDate();
}
你的程序调用ApplicationEnvironment实现类而纯岁不颂知是Date类,这样你就可以骗过程做樱睁序当前时间的限制.
这个可以在实体中羡手这个属带派歼性的蠢冲GET方法里加个判断
if(null == this.date){
return new Date();
}else{
return this.date;
}
不懂你的意思
在构造函数中设默认值(new Date())