计算java中每三个月的第三个星期一?

时间:2015-04-09 11:36:26

标签: java date

LocalDate date1 = new LocalDate(2015, 3, 22);           
LocalDate date2 = new LocalDate(2015, 9, 30);           
PeriodType monthDay = PeriodType.yearMonthDay().withYearsRemoved();

Period difference = new Period(date1, date2, monthDay);             
int months = difference.getMonths();            
int days = difference.getDays();                
int alertMonth = 2;             
int intervalLoop = date2.getMonthOfYear() / alertMonth ;            
for(int i=date1.getMonthOfYear();i<date2.getMonthOfYear();i++){             
         int intervalTime = i * alertMonth;             
         if(intervalTime >13){

               return;          
         }else{
  LocalDate d = getNDayOfMonth( DateTimeConstants.WEDNESDAY, 2, i, 2015);
  System.out.println("month----> "+i+" "+d);

1 个答案:

答案 0 :(得分:0)

此代码可能有所帮助..

DateTime urDate = DateTime(date);                               //Your Date time
DateTime afterThreeMonths = urDate.plusMonths(6);               //Add 3 months to your Date
afterThreeMonths.withDayOfWeek(DateTimeConstants.MONDAY);       //Find next monday  
afterThreeMonths.plusWeeks(2);                                  //Add two more weeks to the first monday.

注意:我从未运行过此代码。试着自己找出来。