I am trying to create a gag calendar app and need some help getting the algorithm correct to create a calendar like this:
Sunday
Jan Feb .. Dec
2 6 4
9 13 11
16 20 18
23 27 25
30
Monday
Jan Feb .. Dec
3 7 5
10 14 12
17 21 19
24 28 26
31
And so on... I have the code from http://helpdesk.objects.com.au/java/display-a-month-as-a-calendar
But can't get the algorithm to do it like above.
Model the desired output as a three-dimensional array
private static final int DAYS_IN_WEEK = 7;
private static final int WEEKS_IN_MONTH = 5;
private static final int MONTHS_IN_YEAR = 12;
Integer dayNumber[DAYS_IN_WEEK][WEEKS_IN_MONTH][MONTHS_IN_YEAR];
Allocate it and fill it using standard Calendar methods that give you the indices, then iterate over it in row-major order to produce the output.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.