Results 1 to 1 of 1
Thread: Current month
-
Current month
Following is an interesting example that displays calendar of the current month on the console.
Java Code:GregorianCalendar d = new GregorianCalendar(); int today = d.get(Calendar.DAY_OF_MONTH); int month = d.get(Calendar.MONTH); d.set(Calendar.DAY_OF_MONTH, 1); int weekday = d.get(Calendar.DAY_OF_WEEK); System.out.println("Sun Mon Tue Wed Thu Fri Sat"); for (int i = Calendar.SUNDAY; i < weekday; i++) System.out.print(" "); do { int day = d.get(Calendar.DAY_OF_MONTH); if (day < 10) System.out.print(" "); System.out.print(day); if(day == today) System.out.print("* "); else System.out.print(" "); if (weekday == Calendar.SATURDAY) System.out.println(); d.add(Calendar.DAY_OF_MONTH, 1); weekday = d.get(Calendar.DAY_OF_WEEK); } while (d.get(Calendar.MONTH) == month); if (weekday != Calendar.SUNDAY) System.out.println();
Similar Threads
-
Month and year program code!!!!HELP PLEASE!!!
By chitwood in forum New To JavaReplies: 4Last Post: 10-13-2010, 01:21 PM -
Datepicker Calender - month change event - jquery
By rmpatel101 in forum Advanced JavaReplies: 0Last Post: 04-02-2008, 06:42 PM -
Switch statement to display the name of the month
By Java Tip in forum Java TipReplies: 0Last Post: 01-04-2008, 09:32 AM -
date one month back
By senzacionale in forum New To JavaReplies: 1Last Post: 12-24-2007, 09:02 PM -
How can i get current directory?
By Ashley in forum New To JavaReplies: 1Last Post: 05-26-2007, 01:21 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks