Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Help with program  RSS feed

 
Zeeshan waheed
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I am attempting to write a code to display a calendar with the name of the month displayed, i must ask the user to input a month and a year and then the calendar should be displayed for that month and year. to print a the calendar a method called printCalendar must be used. i am having a lot of trouble attempting this and any help or advice woudl be appreciated.
Thanks a lot
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you printing in a console, a GUI or to a printer? Take a look at the API for GregorianCalendar and Calendar to do the actual work. You can get the first day of the week like this:

Note that days are 1-indexed and begin on SUNDAY, ie Calendar.SUNDAY = 1.
 
Zeeshan waheed
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am printing off to a GUI. Where would i find the API for the gregorianCalendar?
i was told that to do this i need a repeat loop of all the differant formats of the look for the calendar then its just the matter of printing the name of hte month and finding the right calendar picture to print up
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JAVA 1.4.2 API (javadocs)
It sounds like you have some graphics of calendars already created. There is a finite set of month formats. There are 28, I think because you have 28, 29, 30 and 31 day months and they can start on one of 7 days. You can determine the first day of the week as indicated above and to determine how many days in the month you can do this:

With the starting day and the number of days in the month that nails down the correct calender.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!