2018-2-6 16:53:13 更新 Eclipse 4.7.2(下载后.zip改为.jar): org.eclipse.text_3.6.100.v20170203-0814.jar

点击下载Eclipse插件  org.eclipse.text_3.5.300.v20130515-1451.jar  覆盖下图所示的jar文件。

/*******************************************************************************
* 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 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());
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));
}
} /**
* 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());
final SimpleDateFormat df = new SimpleDateFormat("HH:mm");
return df.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 日期和时间格式自定义的更多相关文章

  1. 不修改系统日期和时间格式,解决Delphi报错提示 '****-**-**'is not a valid date and time

    假如操作系统的日期格式不是yyyy-MM-dd格式,而是用strtodate('2014-10-01')) 来转换的话,程序会提示爆粗 '****-**-**'is not a valid date ...

  2. style不同取值对应的日期、时间格式

    from : http://www.cnblogs.com/Gavinzhao/archive/2009/11/10/1599690.html sql server2000中使用convert来取得d ...

  3. Java 8新增的日期、时间格式器

    一 获取DateTimeFormatter对象的三种方式 直接使用静态常量创建DateTimeFormatter格式器 使用代码不同风格的枚举值来创建DateTimeFormatter格式器 根据模式 ...

  4. 如何修改Django中的日期和时间格式 DateTimeField

    html页面从数据库中读出DateTimeField字段时,显示的时间格式和数据库中存放的格式不一致,比如数据库字段内容为2017-06-03 13:00:00,但是页面显示的却是Apr. 03, 2 ...

  5. Django中的日期和时间格式 DateTimeField

    创建django的model时,有DateTimeField.DateField和TimeField三种类型可以用来创建日期字段,其值分别对应着datetime().date().time()三中对象 ...

  6. obj 转为Json 时间格式自定义

    var tb = evnWarningBll.GatWarning();             var  timeFormat = new IsoDateTimeConverter();       ...

  7. 日期和时间格式(ISO 8601)

    参考 ISO 8601 - Wikipedia ISO 8601 Date and time format

  8. matlab中datest() 将日期和时间转换为字符串格式

    来源:https://ww2.mathworks.cn/help/matlab/ref/datestr.html?searchHighlight=datestr&s_tid=doc_srcht ...

  9. db2 日期时间格式

    db2日期和时间常用汇总 1.db2可以通过SYSIBM.SYSDUMMY1.SYSIBM.DUAL获取寄存器中的值,也可以通过VALUES关键字获取寄存器中的值. SELECT 'HELLO DB2 ...

随机推荐

  1. C++常见笔试面试要点以及常见问题

    1. C++常见笔试面试要点: C++语言相关: (1) 虚函数(多态)的内部实现 (2) 智能指针用过哪些?shared_ptr和unique_ptr用的时候需要注意什么?shared_ptr的实现 ...

  2. android绘制圆形图片的两种方式

    看下效果先 下面有完整的示例代码 使用BitmapShader(着色器) 我们在绘制view 的时候 就是小学上美术课 用水彩笔在本子上画画 使用着色器绘制圆形图片最简单的理解方式 就是把bitmap ...

  3. linux 如何对文件解压或打包压缩

    tar命令用与对文件打包压缩或解压,格式: tar [选项] [文件] 打包并压缩文件: tar -czvf  压缩包名 .tar.gz 解压并展开压缩包: tar -xzvf  压缩包名 .tar. ...

  4. spring mvc 数据校验

    1.需要导入的jar包: slf4j-api-1.7.21.jar validation-api-1.0.0.GA.jar hibernate-validator-4.0.1.GA.jar 2.访问页 ...

  5. [PHP源码阅读]array_pop和array_shift函数

    上篇文章介绍了PHP添加元素到数组的函数,那么当然有从数组中删除元素.array_pop和array_shift只从数组的头或尾删除一个元素.经过阅读源码,发现这两个函数的实现都是调用了同一个函数-- ...

  6. 《图解HTTP》读书笔记

    目前国内讲解HTTP协议的书是在太少了,记忆中有两本被誉为经典的书<HTTP权威指南>与<TCP/IP详解,卷1>,但内容晦涩难懂,学习难度较大.其实,HTTP协议并不复杂,理 ...

  7. .NET 基础一步步一幕幕[面向对象前言]

    面向对象前言 2017年的第一篇博文,好久不写博文了,赶紧补上,感觉在以前的<.NET 基础一步步一幕幕>系列博客中,简短的小知识点已经介绍的差不多的(PS:如果还有别的基础知识点我没有介 ...

  8. 关于百度编辑器UEditor的一点说明

    大家在使用的时候要特别注意editor_config.js中的“URL”这个参数 我的理解:1.这个参数是editor整个结构的总路径          2.首先要把这个路径配置好了.才能正常的显示, ...

  9. JMeter压力测试

    Apache JMeter是Apache组织开发的基于Java的压力测试工具.用于对软件做压力测试,它最初被设计用于Web应用测试但后来扩展到其他测试领域. 它可以用于测试静态和动态资源例如静态文件. ...

  10. 计算照片的面积(UWP篇)

    今天先说UWP应用程序上计算照片面积的方法,改天有空,再说说WPF篇. 其实计算照片面积的原理真TMD简单,只要你有本事读到照片的像素高度和宽度,以及水平/垂直方向上的分辨率(DPI)就可以了.计算方 ...