Online Hibernate Training just in Rs. 1000

One week online training in Hibernate ORM framework. Learn Hibernate Framework and enhance your skills. Best Online Hibernate training at 90% discount. Join Now!! Offer is valid Only for limited Period!!! Online Training

Determining the Day-of-Week for a Particular Date

This section simply show the current day in word i.e. the Day of Week for a particular date.

Ads

Tutorials   
How to read properties file in Java? Generate random numbers in Java Cloneable Interface in Java What is the flaw with the Stack class? List In Java Java Stack Example HashSet In Java Enumeration in java How to generate random number in java Iterator in java Queue in java Transient Java Keyword clone method in Java Java Queue example Logger in Java Java current date - How to get current date in Java Collection : LinkedList Example Collection : ArrayList Example Random alpha numeric string of fixed size Java List Iterator Example The Hashtable Class The BitSet class Java Vector Java Enumeration Data Structures in Java Java Transient Variable Java Date Format Example Java Properties File Example Map.Entry Java Interface Java Property File java preferences,Change the value of Preferences by user Retrieving a Preference Node Java hasNext Write Keys and Values to the Properties file in Java Get All Keys and Values of the Properties files in Java Properties file in Java Properties file in Java Determining If a Preference Node Contains a Specific Value Change the value of Preferences by user Clone method example in Java Implementing a Simple Event Notifier Determining When a Preference Node Is Added or Removed Listening for Changes to Preference Values in a Preference Node Importing Preferences Finding a Preference in a Preference Tree Retrieving the Parent and Child Nodes of a Preference Node Determining If a Preference Node Exists Removing a Preference Node Creating a Preference Node Getting the Maximum Size of a Preference Key and Value
Ads

Determining the Day-of-Week for a Particular Date

     

This section simply show the current day in word i.e. the Day of Week for a particular date. Here, you can learn about the way of doing that.

Following program helps you for showing the current day in word. This program gets the day of the week using Calendar.DAY_OF_WEEK i.e. the special field of the Calendar class. It returns the numeric value between 1 to 7.

Here, each and every day is specified for the specific returned value like 1-Sunday, 2-Monday, 3-Tueseday, 4-Wednesday, 5-Thursday, 6-Friday and 7-Saturday. These specification is completed in the switch construct.

Here is the code of the program:

import java.util.*;

public class DayOfWeek{
  public static void main(String[] args){
  Calendar cal = Calendar.getInstance();
  int day = cal.get(Calendar.DAY_OF_WEEK);
  System.out.print("Today is ");
  switch(day){
  case 1: System.out.print("Sunday");
  break;
  case 2: System.out.print("Monday");
  break;
  case 3: System.out.print("Tueseday");
  break;
  case 4: System.out.print("Wednesday");
  break;
  case 5: System.out.print("Thursday");
  break;
  case 6: System.out.print("Friday");
  break;
  case 7: System.out.print("Saturday");
  break;
  }
  System.out.print(".");
  }
}

Download this example.

Advertisements

Share on Google+Share on Google+

Determining the Day-of-Week for a Particular Date

Posted on: April 16, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

 

Discuss: Determining the Day-of-Week for a Particular Date  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:1
Betlista
February 14, 2014
Use constants...

Use constants in case, for example case Calendar.MONDAY...

Ads

 

Ads