adsense


Sunday, 25 October 2015

JAVA EXAMPLES DISPLAY WEEK NUMBER OF THE YEAR PAGE 71

COMPUTER LANGUAGES HTML,C,C++.JAVA,.NET AND MULTIMEDIA basics and programs click home button



JAVA EXAMPLES DISPLAY WEEK NUMBER OF THE YEAR



Java Examples - Display week number of the year


Problem Description:
How to find which week of the year, month?
Solution:
The following example displays week no of the year & month.
import java.util.*;

public class Main {
   public static void main(String[] args) throws Exception {
      Date d1 = new Date();
      Calendar cl = Calendar. getInstance();
      cl.setTime(d1);
      System.out.println("today is "
      + cl.WEEK_OF_YEAR+ " week of the year");
      System.out.println("today is a "+cl.DAY_OF_MONTH + 
      "month of the year");
      System.out.println("today is a "+cl.WEEK_OF_MONTH 
      +"week of the month");
   }
}
Result:
The above code sample will produce the following result.
today is 30 week of the year
today is a 5month of the year
today is a 4week of the month


No comments: