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);
Asked
Active
Viewed 221 times
-2

Rahul Tripathi
- 168,305
- 31
- 280
- 331

user3580696
- 23
- 4
-
1so, what did you try so far? what's not working here? – Mysterion Apr 09 '15 at 11:36
-
please any one provide code. – user3580696 Apr 09 '15 at 11:37
-
You should indicate the library you are using (i.e joda time in this case). Also this is not how SO works. – Alexis C. Apr 09 '15 at 11:38
-
code for what? you paste just a mess into a question. don't expect that you will have answer, until you fix question – Mysterion Apr 09 '15 at 11:38
-
Format your code please. – Jens Apr 09 '15 at 11:39
-
"*please any one provide code*" What do you call what you posted? – MadConan Apr 09 '15 at 11:42
-
Bit of effort required... – Tony Hopkinson Apr 09 '15 at 11:43
-
Are you using joda time or java 8? – vikingsteve Apr 09 '15 at 11:51
-
possible duplicate of [Java: How do I get the date of x day in a month ( e.g. Third Monday in February 2012)](http://stackoverflow.com/questions/7946129/java-how-do-i-get-the-date-of-x-day-in-a-month-e-g-third-monday-in-february) – Basil Bourque Apr 09 '15 at 14:47
-
s, i am using joda library in abow code, i want java code for calculate like third monday of every 2 months or 3 months, please any one have provide me. – user3580696 Apr 10 '15 at 07:01
1 Answers
0
This code may help..
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.
NB: I never run this code. Try and find it out urself.

Dileep
- 5,362
- 3
- 22
- 38