I have gsp which has table and i need to display created date time and last modified time of each file which in drive.
I am not getting how to retrieve file properties.can any body answer me.
Advance thanks laxmi.P
When a Groovy class definition declares a field without an access modifier, then a public setter/getter method pair and a private instance variable field is generated which is also known as "property" according to the JavaBeans specification.
From the Tools Main menu select Groovy > Open Script or Recent Scripts. Select the Groovy file and click Open. This opens the selected file in the Groovy editor. Edit the Groovy script.
The result of file.lastModified() is a long we can use to construct a new Date object. We can apply formatting on the Date object. The formatting rules of SimpleDateFormat can be applied.
new File('.').eachFileRecurse { file ->
println new Date(file.lastModified()).format('EEE MMM dd hh:mm:ss a yyyy')
}
You probably want something like:
new File(path-to-your-directory).eachFileRecurse{file->
println file.lastModified()
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With