Results 1 to 1 of 1
Thread: Calendar days mixed up..
- 03-17-2010, 05:08 PM #1
Member
- Join Date
- Mar 2010
- Posts
- 1
- Rep Power
- 0
Calendar days mixed up..
Hi, I'm new to the forum and I'm building a calendar-based program..
Having some difficulties with setting the calendar straight, here is my code:
Now "som" always receives a day ahaid of the first day of the month. Expl: this year in march, the first is on a monday.. What does "som = cal.get(GregorianCalendar.DAY_OF_WEEK);" it gets "2" back. Even though I set the firstday on a monday "cal.setFirstDayOfWeek(1);"Java Code:GregorianCalendar cal = new GregorianCalendar(year, month, 1); //setting calendar for the first of that month cal.setFirstDayOfWeek(1); nod = cal.getActualMaximum(GregorianCalendar.DAY_OF_MONTH); som = cal.get(GregorianCalendar.DAY_OF_WEEK); System.out.println("------------------------------"); System.out.println("Number of days in month: " +nod); System.out.println("First day of month is a (nr): " +som); //Draw calendar for (int i=1; i<=nod; i++){ int row = new Integer((i+som-2)/7); //(1+2-2)/7= 0.11 = 0 int column = (i+som-2)%7; //(1+2-2)%7= //System.out.println("Row: " +row); //System.out.println("Column: " +column); mtblCalendar.setValueAt(i, row, column); } //Apply renderers tblCalendar.setDefaultRenderer(tblCalendar.getColumnClass(0), new tblCalendarRenderer());
How come? Can someone get me some clarity in this?
Thanks alot!
Edit: solved with work aroundLast edited by tomblue84; 03-18-2010 at 09:36 AM. Reason: solved
Similar Threads
-
Mixed Fraction
By x3iancute in forum NetBeansReplies: 2Last Post: 01-19-2010, 03:15 PM -
Mixed Fraction JAVA
By x3iancute in forum JCreatorReplies: 0Last Post: 01-19-2010, 02:39 PM -
swing mixed with awt graphics
By weddy69 in forum AWT / SwingReplies: 2Last Post: 08-31-2009, 08:01 AM -
Mixed language project?
By toadaly in forum NetBeansReplies: 5Last Post: 03-11-2009, 06:29 AM -
No fo days between two dates
By Java Tip in forum Java TipReplies: 0Last Post: 01-28-2008, 09:06 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks