How to show 24-hour-format time instead of the default 12-hour-format time when using time() in live templates?

I have a live template defined to insert a comment containing the current time. I use time() in it.  But it shows the 12-hour-formate date.  How to show 24-hour-format date?

5 comments
Comment actions Permalink

Try using groovyScript():

http://i.imgur.com/TM8WpWj.png

Example for 24h time format:

groovyScript("return String.format('%tH:%<tM', Calendar.instance)")


See http://www.java2s.com/Tutorials/Java/Java_Format/0120__Java_Format_Dates_Times.htm for the format description in case you want to change it (like use "k" instead of "H" for hour without leading zero).

0
Comment actions Permalink

Thanks. Any idea how do I apply this to the File and Code Templates as the default file header *globally*?

https://www.dropbox.com/s/hkff7ek8x9ftx2i/Screenshot%202015-10-28%2017.29.16.png?dl=0

0
Comment actions Permalink

Live templates cannot be included in file and code templates.

0
Comment actions Permalink

How can I use the groovyScript trick to file templates?

0

Please sign in to leave a comment.