[英]Intellij 13 code template for Dates
At the moment I am using Java 7 and I have a utility function that looks like this: 目前,我正在使用Java 7,并且具有如下所示的实用程序功能:
public static Date generateSafeDate(Date date){
return new Date(date.getTime());
}
is there a way to make intellij generate this statement everytime I make a getter with a Date return type: 每当我使用Date返回类型的getter时,有没有办法让intellij生成此语句:
original code: 原始代码:
public Date getDate(){
return this.date;
}
into this: 到这个:
public Date getDate(){
return generateSafeDate(this.date);
}
You can try this. 你可以试试看
Go to Settings -> File and Code Templates -> New Method Body you see 转到设置->文件和代码模板->您看到的新方法主体
#if ( $RETURN_TYPE != "void" )return $DEFAULT_RETURN_VALUE;#end
replace it with 替换为
#if ( $RETURN_TYPE != "Date" )
return new Date($DEFAULT_RETURN_VALUE.getTime());
#else
#if ( $RETURN_TYPE != "void" )return $DEFAULT_RETURN_VALUE;#end
#end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.