gpt4 book ai didi

eclipse - 如何设置Eclipse日期变量格式?

转载 作者:行者123 更新时间:2023-12-02 05:04:25 26 4
gpt4 key购买 nike

如何设置可在 Eclipse 模板中使用的 ${date} 变量的格式?

最佳答案

2016 年 2 月更新:bug 75981已正式修复!
请参阅Jminianswer below

enter image description here

<小时/>

6 年后,2015 年 7 月更新:

下面提到的错误似乎已在 Eclipse 4.x 中修复。
Eric Wang comments below :

@date ${id:date('YYYY-MMM-dd')} ${time} 

this give me English datetime format in eclipse 4.

<小时/>

原始答案2009 Eclipse 3.x

啊啊!为此有一个长期存在的错误:bug 75981

The ${date} variable could be enhanced to accept an argument (similar to other parameterizations added in 3.3M1), e.g. ${d:date(format)}, where format is a pattern for SimpleDateFormat.

唯一的替代方案是修改包 org.eclipse.jface.text 中的类 SimpleTemplateVariableResolver(如 this thread 中所述)。模板。 (这里有一个 example of such an extension )。

这个thread mentions您可以找到该类的来源。

\eclipse\plugins\org.eclipse.platform.source_3.1.0\src\org.eclipse.text_3.1.0\src.zip

示例:

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());
DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
return df.format(new java.util.Date()); } }

关于eclipse - 如何设置Eclipse日期变量格式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1131712/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com