Quote:
Is there a way to convert the unix time used to a normal date and/or time?
It is quite simple
To show a date/time
Code:
def text = new Date().format( "yyyy-MM-dd HH:mm:ss")
show(text)
To get separated values
Code:
def text = Calendar.getInstance().get(Calendar.YEAR)+"-"+
Calendar.getInstance().get(Calendar.MONTH)+"-"+
Calendar.getInstance().get(Calendar.DAY_OF_MONTH)+" "+
Calendar.getInstance().get(Calendar.HOUR_OF_DAY)+":"+
Calendar.getInstance().get(Calendar.MINUTE)+":"+
Calendar.getInstance().get(Calendar.SECOND));
show(text)
Conversion is harder (and the result may suffer from the time zones) :
Code:
def t = getTime()
def text = new Date(t*1000L).format( "yyyy-MM-dd HH:mm:ss"))
show(text)
All those codes will show something like : 2014-11-3 12:14:47
Quote:
Also, is there a way to enter data in a seperate file, a bit of a log?
Yes
Code:
def f= new File('log.txt')
f.append("ok\n")
Sources :
http://groovy.codehaus.org/Getting+Started+GuideIsn't Groovy lovely ?