在Eclipse中如何自动打印当前日期/时间在评论中? [英] In Eclipse how to automatically print current date/time in the comments?

查看:267
本文介绍了在Eclipse中如何自动打印当前日期/时间在评论中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的代码&我需要说的是什么时候是我最后一次修改一段代码。由于当我保存文档时可能很难自动执行此操作,我正在寻找一些半自动解决方案,其中我按快捷键& poof日期/时间出现在我的光标处。

I have element-level comments in my code & I need to say when was the last time I modified a piece of code. Since it might be difficult to do this automatically when I save the document in question, I was looking for some semi-automatic solution where I press a shortcut & poof the date/time appears at my cursor.

例如。

/**
 * modified by @author Chantz last on <ENTER CURRENT DATE TIME HERE>
 */
public class EclipsePrintDateTimePlease {
...

UPDATE
我使用的Eclipse版本是Helios&

UPDATE Eclipse versions I use are Helios & Galileo (I have different workstations).

推荐答案

您没有指定使用哪个版本的Eclipse,除非您是非常旧版本的
,这应该工作:

You didn't specify which version of Eclipse you're using but, unless you are on a very old version, this should work:


  1. 转到Windows /首选项。

  2. 从首选项树中选择Java /代码样式/代码模板。

  3. 在代码模板窗口中,选择您希望
    时间戳出现的注释类型,例如getters,然后单击Edit按钮。在编辑
    模板对话框中,将光标置于模型
    注释中的任何位置,然后单击插入变量...。没有时间戳变量
    (即,显示年,月,日,小时,分钟,秒,
    和微秒的单个变量),但您可以设置日期,
    $ {date} $ {time},以获得第二个准确的东西。这应该是很好的
    足够大多数人....

  4. 我你需要对每个不同的地方做相同的步骤
    要显示时间戳的位置;我不认为有任何方式
    告诉Eclipse在单个
    操作中每个注释的时间戳

  1. Go to Windows/Preferences.
  2. Select Java/Code Style/Code Templates from the preferences tree.
  3. In the code templates window, select the type of comments where you want timestamps to appear, e.g. getters, and click the Edit button. In the Edit Template dialog, positition the cursor wherever you like in the model comment, then click "Insert Variable...". There is no timestamp variable (i.e. a single variable that shows year, month, day, hour, minute, second, and microseconds) but you could do a date and then a time, e.g. ${date}${time}, to get something accurate to the second. That should be good enough for most people....
  4. I think you need to do the same steps for each of the different places where you want the timestamp to appear; I don't think there is any way to tell Eclipse to put a timestamp in every kind of comment in a single operation

这篇关于在Eclipse中如何自动打印当前日期/时间在评论中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆