Monday 12 November 2018

How to use setWeekDate(int weekYear, int weekOfYear, int dayOfWeek) method of GregorianCalendar


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

GregorianCalendarDemo.java

import java.util.GregorianCalendar;

public class GregorianCalendarDemo
{
    public static void main(String[] args)
    {
        GregorianCalendar cal = (GregorianCalendar) GregorianCalendar
                .getInstance();

        System.out.println(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(2030, 11, 2);

        System.out.println(cal.getTime());
    }
}

Output

Mon Oct 08 08:53:54 IST 2018
Mon Mar 11 08:53:54 IST 2030

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

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

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/4cfac93378c4f9d33f18bb5083115d18778294de/BasicJava_2018/GregorianCalendarDemo_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