Sunday, January 5, 2014

Computer's current date, month, year, days of the week

class today
{
  public static void main(String args[])
  {
    //Today's date, month, year, days of the week
    String days[]={"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
    java.util.Date d1=new java.util.Date();
    System.out.println(d1.getDate());
    System.out.println(d1.getMonth()+1);
    System.out.println(d1.getYear()+1900);
    System.out.println(days[d1.getDay()]);
  }
}

No comments:

Post a Comment