import java.util.*; import java.text.*; public class TestRuleCal { public static void main(String[] args) { // Find fifth Tuesday of every month for the next 2 years RuleCal rc = new RuleCal(); GregorianCalendar gcal = new GregorianCalendar(); DateFormat df = DateFormat.getDateInstance(DateFormat.FULL); df.setTimeZone( TimeZone.getDefault() ); for( int i=0; ; i++ ) { Date d = rc.getDayInMonth( RuleCal.FIFTH, Calendar.TUESDAY, gcal.get(Calendar.MONTH), gcal.get(Calendar.YEAR) ); String output = ( d == null ? "doesn't exist." : df.format(d) ); System.out.println( output ); if( i == 24 ) break; gcal.add( Calendar.MONTH, 1 ); } } }