Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
211 views
in Technique[技术] by (71.8m points)

Is there a shortcut for inserting date/time in IntelliJ IDEA?

I'd like to add date/time for comments so that I can know when I did those changes, and I am doing that by hand now because I could not find a shortcut. What a great plus for IntelliJ IDEA to have a shortcut for that!

question from:https://stackoverflow.com/questions/8714779/is-there-a-shortcut-for-inserting-date-time-in-intellij-idea

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can create your own:

  1. In Settings, go to Live Templates
  2. Add a new template with the abbreviation "date"
  3. For "template text", specify $date$. Now the "Edit Variables" button should be enabled.
  4. Edit the variables, and set $date$ to use the expression date().
  5. Enable "Java comment" under the template's context and click OK.

Now when you type "date" and use the default completion gesture (Tab), it will replace "date" with the current date.

You can also make use of the time() expression. Note that it doesn't seem like IntelliJ has great support for specifying the format of this date.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...