Over a million developers have joined DZone.

My Weekly NetBeans Tip (5): Fiddling with Predefined Code Template Variables

· Java Zone

Navigate the Maze of the End-User Experience and pick up this APM Essential guide, brought to you in partnership with CA Technologies

When you create a new class in NetBeans IDE, you automatically get some variables filled in, such as the user name and package name. That's possible because if you go to Tools | Templates, the Java Class template is like this:

<#assign licenseFirst = "/*">
<#assign licensePrefix = " * ">
<#assign licenseLast = " */">
<#include "../Licenses/license-${project.license}.txt">

<#if package?? && package != "">
package ${package};

</#if>
/**
 *
 * @author ${user}
 */
public class ${name} {

}

Here you see predefined template variables such as ${package} and ${user}. In this User FAQ, you can find all the other predefined variables for templates. And more info (including about "project.license") can be found here and here.

But this week I found something new: you can change the display of the date and of the time. So if you use this:

${time?time?string("h/m/s a z")} 

You will get this:

4/53/54 PM CET

Instead of the default provided by ${time}, which is this:

4:53:54 PM  

So, both the predefined variable for time and date can be tweaked quite easily, if you're willing to experiment a bit. 

Thrive in the application economy with an APM model that is strategic. Be E.P.I.C. with CA APM.  Brought to you in partnership with CA Technologies.

Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}