国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

Eclipse 修改注釋的 date time 日期時間格式,即${date}變量格式

2019-11-11 04:20:13
字體:
來源:轉載
供稿:網友

http://blog.csdn.net/zollty/article/details/46459621

Eclipse 修改注釋的 date time 日期時間格式,即${date}變量格式

找到eclipse安裝目錄下面的plugins目錄,搜索 org.eclipse.text ,找到一個jar包,例如我找到的jar包為:org.eclipse.text_3.5.300.v20130515-1451.jar然后打開它,找到這個類: org.eclipse.jface.text.templates.GlobalTemplateVariables我們重寫這個類就行了。(可反編譯,也可以找到源碼,源碼下載地址為:http://Git.eclipse.org/c/platform/eclipse.platform.text.git,下載zip包) PS:如果嫌下載源碼包麻煩,我這里貼出這個文件的源碼,可以直接用(注:這個類很簡單,無多少依賴,所有版本通用,無需擔心jar包的版本問題)

[java] view plain copy PRint?/*******************************************************************************  * 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 com.ibm.icu.text.DateFormat;  import com.ibm.icu.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());          }      }        /**      * 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));          }      }        /**      * 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) {              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$          }      }  }  自行拿去修改就行了。改一下Date Time Year就行了,例如,我修改的結果如下:[java] view plain copy print?/*******************************************************************************  * 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(TextTemplateMessages.getString("GlobalVariables.variable.format.date"));               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(TextTemplateMessages.getString("GlobalVariables.variable.format.time"));              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$          }      }  }  我改成了使用

import Java.text.SimpleDateFormat;import java.util.Calendar;

并且從properties文件中讀取format格式,可以借鑒。

我提供編譯好的class文件供大家下載(下載下面的圖片,把jpg后綴 改成rar后綴,然后打開),替換到原文件即可。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 内丘县| 循化| 甘泉县| 九龙坡区| 虎林市| 徐州市| 五大连池市| 通许县| 股票| 满城县| 康乐县| 上虞市| 洱源县| 天气| 昌吉市| 农安县| 桦甸市| 麻栗坡县| 大理市| 红安县| 盐源县| 阿坝县| 黄陵县| 海阳市| 周口市| 中西区| 鲁山县| 通江县| 甘孜| 古丈县| 且末县| 罗平县| 湘西| 南开区| 含山县| 张掖市| 延津县| 南投县| 铅山县| 朝阳县| 霞浦县|