Re: time condition in rewrite rule along with other rules

Splash Forums Rewrite Users time condition in rewrite rule along with other rules Re: time condition in rewrite rule along with other rules

#22270

Rewrite provides a JodaTime integration module.

<dependency>
<groupId>com.ocpsoft.rewrite</groupId>
<artifactId>rewrite-config-jodatime</artifactId>
<version>1.0.0.Alpha11</version>
</dependency>

With this you can do something like:

return ConfigurationBuilder.begin()
.defineRule()
.when(Direction.isInbound().and(Path.matches("{page}").where("page").matches(".*"))
.and(JodaTime.matches(new TimeCondition() {
@Override
public boolean matches(DateTime date) {
return date.isAfter(new DateMidnight(2013, 1, 1));
}
})))
.perform(Redirect.temporary("/myapp/{page}"));

You can do EVERYTHING with Rewrite! ;)