Rosetta Code:Add a Task: Difference between revisions

→‎Create the page: It will provide any day like Monday, Tuesday, Wednesday, Thursday, Friday , Saturday and Sunday on every month for specific year and also range.
(→‎Example code: --any specific day on every month for specific years)
(→‎Create the page: It will provide any day like Monday, Tuesday, Wednesday, Thursday, Friday , Saturday and Sunday on every month for specific year and also range.)
Line 11:
Come up with a title for your task (look at [[:Category:Programming Tasks|the current tasks]] to see what kind of name you should choose), type it in the search bar, and click "Go". There will be a "Create page" link on the resulting page somewhere. Click that, and you can begin editing.
 
weIt canwill getprovide any last day(monday like Monday,tuesday Tuesday,...sunday) Wednesday, Thursday, Friday , Saturday and Sunday on every month for specific year and also range.
public class LastSunday {
 
/**
* Venkata Janga
* @param args
*/
public static void main(String[] args) {
int year = 2015;
GregorianCalendar calander = new GregorianCalendar(year, 0, 1);
for (String mon : new DateFormatSymbols(Locale.US).getShortMonths()) {
if (!mon.isEmpty()) {
int totalDaysOfMonth = calander.getActualMaximum(Calendar.DAY_OF_MONTH);
calander.set(Calendar.DAY_OF_MONTH, totalDaysOfMonth);
/**
* 1--> FRIDAY
* 2--> THURSDAY
* 3--> WEDNES DAY
* 4--> TUESDAY
* 5--> MONAY
* 6--> SUNDAY
* 7--> SATURADAY
* */
int daysToRollBack = (calander.get(Calendar.DAY_OF_WEEK) + 6) % 7;
int day = totalDaysOfMonth - daysToRollBack;
calander.set(Calendar.DAY_OF_MONTH, day);
System.out.printf("%d %s %d\n", year, mon, day);
calander.set(year,calander.get(Calendar.MONTH) + 1, 1);
}
}
}
 
}
 
===Draft vs non-draft===