package net.sourceforge.phpdt.internal.corext.template.php;
import java.text.DateFormat;
+import java.util.Calendar;
import net.sourceforge.phpdt.internal.corext.template.SimpleTemplateVariable;
import net.sourceforge.phpdt.internal.corext.template.TemplateContext;
return DateFormat.getDateInstance().format(new java.util.Date());
}
}
-
+
+ /**
+ * The year variable evaluates to the current year.
+ */
+ static class Year extends SimpleTemplateVariable {
+ public Year() {
+ super(PHPTemplateMessages.getString("GlobalVariables.variable.name.year"), PHPTemplateMessages.getString("GlobalVariables.variable.description.year")); //$NON-NLS-1$ //$NON-NLS-2$
+ setResolved(true);
+ }
+ public String evaluate(TemplateContext context) {
+ return Integer.toString(Calendar.getInstance().get(Calendar.YEAR));
+ }
+ }
/**
* The time variable evaluates to the current time.
*/