Revision as of 02:16, 15 December 2011 by Dawmail333 (Talk | contribs)

Can you give me a list of all the predefined variables for templates, like ${user} and ${date}?

  • ${date} inserts the current date, in this format: Feb 16, 2008
  • ${encoding} inserts the default encoding, such as: UTF-8
  • ${name} inserts the name of the file.
  • ${nameAndExt} inserts the name of the file, together with its extension.
  • ${package} inserts the name of the package where the file is created.
  • ${time} inserts the current time, in this format: 7:37:58 PM
  • ${user} inserts the user name.
  • ${project.license} based on the value (e.g., 'CDDL'), the license header is found and is inserted into the template.
  • ${project.name} inserts the project name
  • ${project.displayName} inserts the project displayname

For more details, go here.

How do I override those predefined variables?

  1. Go to Tools | Templates.
  2. Scroll to the end of the Template Manager and expand 'User Configuration Properties'.
  3. Select 'User.properties' and click 'Open in Editor'.
  4. Now you can add the above and set your own value, for example:

Now, whenever you have ${user} in a file template, you will find the above value generated into the file that you create using that template.

Note: The ${date} variable is of type String, not type Date. You have to cast it to a Date type then do the format. For example, to show the year only, do this:

<#setting locale="en_AU"> <- Needed if you're in a locale that stores dates differently (e.g. dd/mm/yyyy)

Also, follow this issue, which aims to make the above more discoverable: issue 127490.

Applies to: NetBeans 6.x

Platforms: All

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo