Jump to content

Last Friday of each month: Difference between revisions

m
→‎{{header|Java}}: Nicer look, makes fewer assumptions about the values for the months in Calendar
m (→‎{{header|C++}}: {{libheader|Boost}})
m (→‎{{header|Java}}: Nicer look, makes fewer assumptions about the values for the months in Calendar)
Line 148:
=={{header|Java}}==
{{works with|Java|1.5+}}
<lang java5>import java.utiltext.CalendarDateFormatSymbols;
import java.util.Calendar;
import java.util.GregorianCalendar;
 
Line 176 ⟶ 177:
date.add(Calendar.DAY_OF_MONTH, -1);
}
String monthStr = new DateFormatSymbols().getShortMonths()[month];
System.out.println((date.get(Calendar.MONTH) + 1) + "-"
System.out.println(monthStr +" "+ date.get(Calendar.DAY_OF_MONTH));
}
}
}</lang>
Output (for <code>java LastFriday 2012</code>):
<pre>1-Jan 27
2-Feb 24
3-Mar 30
4-Apr 27
5-May 25
6-Jun 29
7-Jul 27
8-Aug 31
9-Sep 28
10-Oct 26
11-Nov 30
12-Dec 28</pre>
 
=={{header|OCaml}}==
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.