eclipse修改注释日期格式
2016-01-11 11:22
483 查看
编译修改的文件:前提要配置java环境变量
运行命令如下,由于会依赖com.ibm.icu包内容
javac -classpath
E:\eclipse\plugins\com.ibm.icu_3.5.300.v201305151451.jar;E:\eclipse\plugins\org.eclipse.text_3.5.300.v20130515-1451.jar
GlobalTemplateVariables.java
注意:
每个类中的super()函数参数为(String,String),默认反编译出来的源码缺少入参。
日期格式的修改方法可以参考public Date()和public Time()。
运行命令如下,由于会依赖com.ibm.icu包内容
javac -classpath
E:\eclipse\plugins\com.ibm.icu_3.5.300.v201305151451.jar;E:\eclipse\plugins\org.eclipse.text_3.5.300.v20130515-1451.jar
GlobalTemplateVariables.java
注意:
每个类中的super()函数参数为(String,String),默认反编译出来的源码缺少入参。
日期格式的修改方法可以参考public Date()和public Time()。
/******************************************************************************* * Copyright (c) 2000, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation * Sebastian Davids: sdavids@gmx.de - see bug 25376 *******************************************************************************/ package org.eclipse.jface.text.templates; import java.text.SimpleDateFormat; import java.util.Calendar; /** * Global variables which are available in any context. * <p> * Clients may instantiate the classes contained within this class. * </p> * * @since 3.0 */ public class GlobalTemplateVariables { /** The type of the selection variables. */ public static final String SELECTION= "selection"; //$NON-NLS-1$ /** * The cursor variable determines the cursor placement after template edition. */ public static class Cursor extends SimpleTemplateVariableResolver { /** Name of the cursor variable, value= {@value} */ public static final String NAME= "cursor"; //$NON-NLS-1$ /** * Creates a new cursor variable */ public Cursor() { super(NAME, TextTemplateMessages.getString("GlobalVariables.variable.description.cursor")); //$NON-NLS-1$ setEvaluationString(""); //$NON-NLS-1$ } } /** * The word selection variable determines templates that work on a full * lines selection. */ public static class WordSelection extends SimpleTemplateVariableResolver { /** Name of the word selection variable, value= {@value} */ public static final String NAME= "word_selection"; //$NON-NLS-1$ /** * Creates a new word selection variable */ public WordSelection() { super(NAME, TextTemplateMessages.getString("GlobalVariables.variable.description.selectedWord")); //$NON-NLS-1$ } protected String resolve(TemplateContext context) { String selection= context.getVariable(SELECTION); if (selection == null) return ""; //$NON-NLS-1$ return selection; } } /** * The line selection variable determines templates that work on selected * lines. */ public static class LineSelection extends SimpleTemplateVariableResolver { /** Name of the line selection variable, value= {@value} */ public static final String NAME= "line_selection"; //$NON-NLS-1$ /** * Creates a new line selection variable */ public LineSelection() { super(NAME, TextTemplateMessages.getString("GlobalVariables.variable.description.selectedLines")); //$NON-NLS-1$ } protected String resolve(TemplateContext context) { String selection= context.getVariable(SELECTION); if (selection == null) return ""; //$NON-NLS-1$ return selection; } } /** * The dollar variable inserts an escaped dollar symbol. */ public static class Dollar extends SimpleTemplateVariableResolver { /** * Creates a new dollar variable */ public Dollar() { super("dollar", TextTemplateMessages.getString("GlobalVariables.variable.description.dollar")); //$NON-NLS-1$ //$NON-NLS-2$ setEvaluationString("$"); //$NON-NLS-1$ } } /** * The date variable evaluates to the current 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()); } } /** * The year variable evaluates to the current year. */ public static class Year extends SimpleTemplateVariableResolver { /** * Creates a new year variable */ public Year() { super("year", TextTemplateMessages.getString("GlobalVariables.variable.description.year")); //$NON-NLS-1$ //$NON-NLS-2$ } protected String resolve(TemplateContext context) { // return Integer.toString(Calendar.getInstance().get(Calendar.YEAR)); return Integer.toString(Calendar.getInstance().get(Calendar.YEAR)); } } /** * The time variable evaluates to the current time. */ public static class Time extends SimpleTemplateVariableResolver { /** * Creates a new time variable */ public Time() { super("time", TextTemplateMessages.getString("GlobalVariables.variable.description.time")); //$NON-NLS-1$ //$NON-NLS-2$ } /** * {@inheritDoc} */ protected String resolve(TemplateContext context) { final SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss"); return df.format(new java.util.Date()); //return DateFormat.getTimeInstance().format(new java.util.Date()); } } /** * The user variable evaluates to the current user. */ public static class User extends SimpleTemplateVariableResolver { /** * Creates a new user name variable */ public User() { super("user", TextTemplateMessages.getString("GlobalVariables.variable.description.user")); //$NON-NLS-1$ //$NON-NLS-2$ } /** * {@inheritDoc} */ protected String resolve(TemplateContext context) { return System.getProperty("user.name"); //$NON-NLS-1$ } } }
相关文章推荐
- eclipse运行程序显示the user operation is waiting for "building workspace" to complete
- Java并发编程:Callable、Future和FutureTask
- eclipse最常用的快捷键整理
- Java通用数据访问层 Uncode-DAL
- Java中的return关键字
- 关于spring mvc拦截器拦截js文件等导致无法正常使用问题的解决
- Java学习推荐书目
- java中static作用详解
- Java验证是否是身份证号
- Java中static作用详解
- Java日志:集成slf4j和logback
- maven+eclipse+groovy环境配置
- java初始化
- 从头认识java-17.3 线程状态
- java swing中常用的控件设置为背景透明的栗子
- java 获取可用的打印机列表 和 当前默认打印机
- eclipse配置maven出现这个问题,求大神解决
- spring自动扫描的问题
- Java之Pcap文件解析(三:解析文件)
- Spring3 MVC请求参数获取的几种方法