- Jan 8, 2008
不是很习惯,如果想改变这种格式,比如想改为:
- 2008-1-8
2.从http://wiki.eclipse.org/index.php/CVS_Howto下载eclipse的源码,主要下载org.eclipse.text包下的类
3.找到org.eclipse.jface.text.templates.GlobalTemplateVariables这个类,然后打开进行修改。找到代码:
- public static class Date extends SimpleTemplateVariableResolver {
- /**
- * Creates a new date variable
- */
- public Date() {
- super("date", TextTemplateMessages.getString("GlobalVariables.variable.description.date")); //$NON-NLS-1$ //$NON-NLS-2$
- }
- protected String resolve(TemplateContext context) {
- return DateFormat.getDateInstance().format(new java.util.Date());
- }
- }
然后修改为:
- public static class Date extends SimpleTemplateVariableResolver {
- /**
- * Creates a new date variable
- */
- public Date() {
- super("date", TextTemplateMessages.getString("GlobalVariables.variable.description.date")); //$NON-NLS-1$ //$NON-NLS-2$
- }
- protected String resolve(TemplateContext context) {
- // return DateFormat.getDateInstance().format(new java.util.Date());
- final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
- return df.format(new java.util.Date());
- }
- }
然后再将其重新编译打包即可。
最后覆盖掉eclipse\plugins下的org.eclipse.text_3.3.0.v20070606-0010.jar这个jar包(org.eclipse.text_XXXX.jar包),只是日期不同而已。
转载:http://ttitfly.javaeye.com/blog/154044
类别:Eclipse 查看评论