Friday, April 07, 2006

Code Contest

Essa história começou aqui. A segunda edição está proposta no blog do Daniel Quirino. Achei uma boa para brincar com a Time and Money library, do Eric Evans. Aqui vai a minha submissão:

package cc;

import java.io.File;
import java.util.TimeZone;

import com.domainlanguage.time.*;
import com.domainlanguage.timeutil.Clock;

public class DeleteOldFiles {
public static void main(String[] args) {
Clock.setDefaultTimeZone(TimeZone.getDefault());
CalendarInterval lastWeek =
Duration.weeks(1).subtractedFrom(Clock.today()).through(Clock.today());

for (File f : new File("D:\\tmp\\backup").listFiles()) {
TimePoint lastModified = TimePoint.from(f.lastModified());

if (lastWeek.includes(lastModified))
f.delete();
}
}
}

Só não tente rodar, porque não vai dar certo. Encontrei um bugzinho na biblioteca e mandei um patch, daqui a um tempo a versão no CVS deve ser atualizada.

2 comments:

Benny said...

Like a immediate result, we're becoming rolex replica uk therefore most of the time "Which you ought to We purchase, the Rolex or perhaps a Tudor. inch There are lots of, numerous points to consider through prices in order to high quality rolex replica sale with delivery as well as actions, through background in order to reputation, as well as through style in order to replica watches uk. All of us do all of the difficult meet your needs as well as in comparison both of these incredible manufacturers with this comprehensive, hands-on assessment overview of the actualhublot replica uk and also the Tudor History Dark These types of rolex replica uk. All of us may certainly try to appear at the significant specs as well as functions, essentially each and every element you need to consider prior to creating the mind to visit along with possibly one of these simple items. Both tend to be truly incredible and therefore greatly well-liked wrist watches nevertheless, even though these people perform appear instead rolex replica uk in the beginning, underneath the area these people are much more diverse from a person actually thought.

opbest said...


I’ve recently started a site, the information you offer on this site has helped me greatly. Thanks for all of your time & work.

Also visit my webpage - 강남안마

(freaky)