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. 【算法】(查找你附近的人) GeoHash核心原理解析及代码实现

    本文地址 原文地址 分享提纲: 0. 引子 1. 感性认识GeoHash 2. GeoHash算法的步骤 3. GeoHash Base32编码长度与精度 4. GeoHash算法 5. 使用注意点( ...

  2. Linux虚拟化学习笔记<一>

    关于虚拟化,原理的东西是非常复杂的,要想完全理解,没有足够的耐心是不不能完全学透这部分内容的.那下面我主要以资源汇总的形式把一些资料罗列出来,帮助大家快速理解虚拟化,快速使用和配置. 为什么要虚拟化: ...

  3. nuget常用命令

    nuget命令的用法: 一.安装 1.安装指定版本类库install-package <程序包名> -version <版本号> 2.安装到指定的项目install-packa ...

  4. [异常解决] windows用SSH和linux同步文件&linux开启SSH&ssh client 报 algorithm negotiation failed的解决方法之一

    1.安装.配置与启动 SSH分客户端openssh-client和openssh-server 如果你只是想登陆别的机器的SSH只需要安装openssh-client(ubuntu有默认安装,如果没有 ...

  5. Spring Batch在大型企业中的最佳实践

    在大型企业中,由于业务复杂.数据量大.数据格式不同.数据交互格式繁杂,并非所有的操作都能通过交互界面进行处理.而有一些操作需要定期读取大批量的数据,然后进行一系列的后续处理.这样的过程就是" ...

  6. CSS样式表分类

    1.内联样式表 <p  style="font-size:11px;">内联样式表</p> 2.内嵌样式表 写在head标签里 <style  typ ...

  7. Struts2拦截器的执行过程浅析

    在学习Struts2的过程中对拦截器和动作类的执行过程一度陷入误区,特别读了一下Struts2的源码,将自己的收获分享给正在困惑的童鞋... 开始先上图: 从Struts2的图可以看出当浏览器发出请求 ...

  8. DUILIB入门使用说明整理

    整理自博客上对DUILIB的操作使用的博客文章 一.DuiLib操作入门 1.DuiLib入门简明教程 -- 前言 2.DuiLib入门简明教程 -- VS环境配置 3.DuiLib入门简明教程 -- ...

  9. Android-TextView跑马灯效果

    要实现跑马灯还是比较简单的. 同时有几个需要注意的点,先上代码: public class MTView extends TextView { public MTView(Context contex ...

  10. salesforce 零基础学习(六十)Wizard样式创建数据

    项目中表之间关联关系特别多,比如三个表中A,B,C  C作为主表,A,B作为从表,有时候C表需要创建数据时,同时需要创建A,B两个表的数据,这种情况下,使用Wizard样式会更加友好. 以Goods_ ...