eclipse/MyEclipse 注释日期格式

在用Eclipse Kepler自动生成日期注释的时候,中文的日期格式一直不能让人满意。但在Java中也就算了,今晚用Eclipse做Python开发。出现中文导致编译无法进行。然后就开始解决日期格式化问题。
首先参考:http://www.cnblogs.com/hoojo/archive/2011/03/21/1990070.html

         http://www.coderli.com/eclipse-template-variable
但是,因为英文太差,在http://wiki.eclipse.org/index.php/CVS_Howto中找不到下载地址。于是,用jd-gui反编译org.eclipse.text_3.5.300.v20130515-1451.jar。

按照上述链接文章中的做法,修改如下:

在org.eclipse.jface.text.templates.GlobalTemplateVariables类中做如下修改:


public class GlobalTemplateVariables$Date extends SimpleTemplateVariableResolver
{
  public GlobalTemplateVariables$Date()
  {
    super("date", TextTemplateMessages.getString("GlobalVariables.variable.description.date"));
  }
  protected String resolve(TemplateContext context) {
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
    return df.format(new Date());
  }
}
public class GlobalTemplateVariables$Time extends SimpleTemplateVariableResolver
{
  public GlobalTemplateVariables$Time()
  {
    super("time", TextTemplateMessages.getString("GlobalVariables.variable.description.time"));
  }

  protected String resolve(TemplateContext context)
  {
    SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");
    return df.format(new Date());
  }
}

因为是反编译的,代码本身就会报错。还好的就是GlobalTemplateVariables中import的类不多,就ibm的两个类。在网络上查询,获得这两个类的源代码(http://opensourcejavaphp.net/java/icu4j/com/ibm/icu/util/Calendar.java.html和http://opensourcejavaphp.net/java/icu4j/com/ibm/icu/text/DateFormat.java.html),拷贝到项目中。编译通过。

 发现:


直接将这两个class文件覆盖掉org.eclipse.text_3.5.300.v20130515-1451.jar中的文件。
重启Eclipse。

转载于:https://my.oschina.net/guanzhenxing/blog/282219

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值