Here a monthly iterating solution (remember there cannot be more than 14 months between two such dates) which is probably better than a daily iterating solution. I write it on base of JSR-310 in pure Java - not tested, therefore no guarantee (and I don't know to write Scala so you have to adapt it to your needs):
public static final TemporalAdjuster LAST_FRIDAY_13 = (Temporal temporal) -> {
LocalDate test = LocalDate.from(temporal);
// move to last 13th of month before temporal
if (test.getDayOfMonth() <= 13) {
test = test.minus(1, ChronoUnit.MONTHS);
}
test = test.withDayOfMonth(13);
// iterate monthly backwards until it is a friday
while (test.getDayOfWeek() != DayOfWeek.FRIDAY) {
test = test.minus(1, ChronoUnit.MONTHS);
}
return test;
}
Note that the adjuster is stored as static constant (what is also recommended by the spec lead Stephen Colebourne). Then you can go and use this adjuster this way:
System.out.println(LocalDate.of(2012, 12, 12).with(LAST_FRIDAY_13));
// Output: 2012-07-13
By the way, you asked for a solution also in other libraries. Well, if you can wait for some few weeks (3-4) then I will provide a very similar solution using my new time library which would only require Java 6+. And you can surely translate the shown code to JodaTime, too (should be more or less straight away).