Friday 20 July 2018

How to use setWeekDate(int weekYear, int weekOfYear, int dayOfWeek) method of Java.util.calendar


Click here to watch on Youtube: 
https://www.youtube.com/watch?v=k6MQRizWITY&list=UUhwKlOVR041tngjerWxVccw

CalendarDemo.java

import java.util.Calendar;

public class CalendarDemo
{
    public static void main(String[] args)
    {
        Calendar cal = Calendar.getInstance();
        System.out.println("Before setWeekDate = "+cal.getTime());
       
        /*
         * Parameters:
         *
         * weekYear - the week year
         *
         * weekOfYear - the week number based on weekYear
         *
         * dayOfWeek - the day of week value: one of the constants for
         * the DAY_OF_WEEK field: SUNDAY, ..., SATURDAY.
         */

        cal.setWeekDate(2013, 11, 4);
        System.out.println("After setWeekDate  = "+cal.getTime());
    }
}

Output

Before setWeekDate = Fri Jun 29 09:47:50 IST 2018
After setWeekDate  = Wed Mar 13 09:47:50 IST 2013

Click the below link to download the code:
https://sites.google.com/site/ramj2eev2/java_basics/CalendarDemo_setWeekDate.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava_2018/CalendarDemo_setWeekDate

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/fcab7bc6a80f12c850b8ccc28d71601c94666bbb/BasicJava_2018/CalendarDemo_setWeekDate/?at=master

See also:
  • All JavaEE Videos Playlist
  • All JavaEE Videos
  • All JAVA EE Links
  • Spring Tutorial
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial
  • Cooking Tutorial
  • No comments:

    Post a Comment