Selasa, 05 Juni 2012

Program java Kalender

import java.util.*;
public class yearCalendar
    {
        public static void yearCalendar(int year)
            {
                GregorianCalendar a = new GregorianCalendar();
                int today = a.get(GregorianCalendar.DAY_OF_MONTH);
                int month1 = a.get(GregorianCalendar.MONTH);
                int year1 = a.get(GregorianCalendar.YEAR);
                a.set(GregorianCalendar.YEAR,year);
                System.out.println();
                System.out.println("    YEAR : "+year);
                for(int i=0;i<12;i++)
                    {
                        a.set(GregorianCalendar.MONTH,i);
                        a.set(GregorianCalendar.DAY_OF_MONTH,1);
                        int month = a.get(GregorianCalendar.MONTH);
                        int weekday = a.get(GregorianCalendar.DAY_OF_WEEK);
                        switch(month)
                    {
                        case 0:
                        System.out.println();
                        System.out.println("        JANUARY            ");
                        System.out.println();
                        break;
                        case 1:
                        System.out.println();
                        System.out.println("        FEBRUARY           ");
                        System.out.println();
                        break;
                        case 2:
                        System.out.println();
                        System.out.println("         MARCH            ");
                        System.out.println();
                        break;
                        case 3:
                        System.out.println();
                        System.out.println("         APRIL           ");
                        System.out.println();
                        break;
                        case 4:
                        System.out.println();
                        System.out.println("          MAY            ");
                        System.out.println();
                        break;
                        case 5:
                        System.out.println();
                        System.out.println("          JUNE          ");
                        System.out.println();
                        break;
                        case 6:
                        System.out.println();
                        System.out.println("          JULY            ");
                        System.out.println();
                        break;
                        case 7:
                        System.out.println();
                        System.out.println("         AUGUST           ");
                        System.out.println();
                        break;
                        case 8:
                        System.out.println();
                        System.out.println("       SEPTEMBER            ");
                        System.out.println();
                        break;
                        case 9:
                        System.out.println();
                        System.out.println("        OCTOBER           ");
                        System.out.println();
                        break;
                        case 10:
                        System.out.println();
                        System.out.println("        NOVEMBER            ");
                        System.out.println();
                        break;
                        case 11:
                        System.out.println();
                        System.out.println("        DECEMBER           ");
                        System.out.println();
                        break;
              }
                        System.out.println("Sun Mon Tue Wed Thu Fri Sat");
                        for(int j=GregorianCalendar.SUNDAY; j<weekday;j++)
                            {
                                System.out.print("    ");
                            }
                        do
                            {  
                         int day = a.get(GregorianCalendar.DAY_OF_MONTH);
                          if(day<10)
                                    {
                                        System.out.print(" "+day);
                                    }
                                   
                                else if(day>=10)
                                    {
                                        System.out.print(day);
                                    }
                                    if(day == today&&month1 == month&&year == year1)
                System.out.print("* ");
                else
                System.out.print("  ");
                                 if(weekday == GregorianCalendar.SATURDAY)
                                    {
                                        System.out.println();
                                    }
                                a.add(GregorianCalendar.DAY_OF_MONTH,1);
                                weekday = a.get(GregorianCalendar.DAY_OF_WEEK);
                            }
                      while(a.get(GregorianCalendar.MONTH) == month);
                    if(weekday != GregorianCalendar.SUNDAY)
                    {
                   System.out.println();
                     }
                    }
                    System.out.println();
                System.out.println("Note : '*' over any digit is current date");
                System.out.println("If it is not displayed then year might not be current year");
                }
            }

0 komentar:

Posting Komentar

resep donat empuk ala dunkin donut resep kue cubit coklat enak dan sederhana resep donat kentang empuk lembut dan enak resep es krim goreng coklat kriuk mudah dan sederhana resep es krim coklat lembut resep bolu karamel panggang sarang semut

Copyright © Deja Area | Powered by Blogger

Design by Anders Noren | Blogger Theme by NewBloggerThemes.com | BTheme.net      Up ↑