Reputation: 99
When I create a new Java file in NetBeans, I get auto documentation for @author
. How can I setup NetBeans that is also documents the time and date of creation of the class?
I know NetBeans can do it as I get the time and date of creation in new CSS files by default.
Upvotes: 1
Views: 1850
Reputation: 855
@MadProgrammer answered well. Just in case as an addition to this answer. U can optionally add properties in the User.properties
file which is read by the various templates in the Tools -> Templated ->* configs
. So if u want to add version
to your Java classes
. you can define the @version
in the Java class template and then define the property in the User.properties file as in the following
In Your Java class template
....
/**
* ${date} ${time}
* ${version}
* ...other
*/
U can then set these properties in the User.properties
file as
version=1.0.0
etc
Upvotes: 2
Reputation: 347194
You can change the template files in Netbeans. Go to Tools|Templates
. From the available templates, find the one you want to change, let's say Java|Java Class
, then select Open in Editor
Then goto to FaqTemplateVariables for list of available template variables. In your case, you're looking for ${date}
and {$time}
Then you modify the template the way want, for example...
<#assign licenseFirst = "/*">
<#assign licensePrefix = " * ">
<#assign licenseLast = " */">
<#include "${project.licensePath}">
<#if package?? && package != "">
package ${package};
</#if>
/**
*
* @author ${user}
* ${date} ${time}
*/
public class ${name} {
}
Then simple create a new "Java Class" - File|New File|Java|Class
and it should then generate a file similar to this...
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package my.awesome.library;
/**
*
* @author noob
* 25/06/2017 3:19:39 PM
*/
public class Test {
}
Now, you'll probably have to go through a number of the other templates and update them, but that gives you a place to start
Upvotes: 3