/* &time is a record field defined as Time */
Local datetime &dateTime = DateTime6(1900, 1, 1, Hour(&time), Minute(&time), Second(&time));
Local string &formattedTime = DateTimeToLocalizedString(&dateTime, "h:mm a");
Friday, August 21, 2009
PeopleCode Time formatting
Had a record with a Time field, took a little while to figure out how to format the value since you can't pass a Time value directly into the builtin DateTimeToLocalizedString function.
Thursday, June 25, 2009
Groovy: Find files modified in the last X days
On a recent project there was a requirement to search a directory (and all sub-directories) for any files (all files were images) changed in the last 7 days and load them into a database table. The code was being written in Groovy and being lazy I just used the *nix find command and processed the command output. I wanted to avoid writing the code to recurse the directories thinking it would be easier to write, read and maintain if I just processed the find command output.
I took a look today and found out how easy Groovy makes this, so when I have a chance I'll rewrite using the code below to make it pure Groovy and portable between *nix and Windows.
I took a look today and found out how easy Groovy makes this, so when I have a chance I'll rewrite using the code below to make it pure Groovy and portable between *nix and Windows.
File rootDir = new File("d:/temp") // arg[0] == d:/temp
long checkTime = new Date().minus(7).time // arg[1] == 7
rootDir.eachFileRecurse {
if (it.isFile() && it.lastModified() >= checkTime) {
println "${it} [${new Date(it.lastModified())}]"
// call the method to load this image file...
}
}
Tuesday, June 9, 2009
Using Groovy to pad a file
The other day someone asked me if there was a quick way to right-pad lines in a file with spaces to a certain length. I couldn't find a setting to do this in my favorite text editor Notepad++, so I thought I'd see what it would take to do in Groovy.
Not a very exciting script, but I truly admire how much you can do with Groovy in just a few lines of code.
Not a very exciting script, but I truly admire how much you can do with Groovy in just a few lines of code.
def outfile = new File("out.txt")
def infile = new File("in.txt")
outfile.withWriter { output ->
infile.eachLine { input ->
output.writeLine(input.padRight(200, " "))
}
}
Wednesday, May 27, 2009
CommunityOne West 2009
Wow, last post to this blog is from September last year. We are really lagging. Been busy around here. But back to the topic of the post...
The Sun CommunityOne West conference is this coming Monday, June 1, 2009 at the Moscone Center. This could be the last hurrah for the CommunityOne conference (at least as we know it). Hopefully Oracle will keep it rolling next year.
For additional info on the conference: http://developers.sun.com/events/communityone/2009/west/index.jsp
Here are the sessions I am planning to attend next Monday:
(S304328) Taking Advantage of Subversion's New Features
(S304431) Apache Trinidad in Action
(S304296) Sexier Software with Flex and Java™ Technology
(S303767) RIAs Done Right: Grails, Flex, and Ext GWT
(S304040) Social-Enable Your Web Apps with OpenSocial
(S308519) Building Belonging
The Sun CommunityOne West conference is this coming Monday, June 1, 2009 at the Moscone Center. This could be the last hurrah for the CommunityOne conference (at least as we know it). Hopefully Oracle will keep it rolling next year.
For additional info on the conference: http://developers.sun.com/events/communityone/2009/west/index.jsp
Here are the sessions I am planning to attend next Monday:
(S304328) Taking Advantage of Subversion's New Features
(S304431) Apache Trinidad in Action
(S304296) Sexier Software with Flex and Java™ Technology
(S303767) RIAs Done Right: Grails, Flex, and Ext GWT
(S304040) Social-Enable Your Web Apps with OpenSocial
(S308519) Building Belonging
Subscribe to:
Posts (Atom)