Monday 29 October 2018

How to use getActualMaximum(int field) and getActualMinimum(int field) methods of GregorianCalendar


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

GregorianCalendarDemo.java

import java.util.GregorianCalendar;

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

        /*
         * Parameters:
         *
         * field - the calendar field
         *
         * Returns:
         *
         * the maximum of the given field for the time value of this
         * GregorianCalendar
         */

        int max = gCal.getActualMaximum(GregorianCalendar.DAY_OF_MONTH);
        System.out.println("Actual Maximum, DAY_OF_MONTH = " + max);

        max = gCal.getActualMaximum(GregorianCalendar.MONTH);
        System.out.println("Actual Maximum, MONTH = " + max);

        /*
         * Parameters:
         *
         * field - the calendar field
         *
         * Returns:
         *
         * the minimum of the given field for the time value of this
         * GregorianCalendar
         */

        int min = gCal.getActualMinimum(GregorianCalendar.DAY_OF_MONTH);
        System.out.println("Actual Minimum, DAY_OF_MONTH = " + min);

        min = gCal.getActualMinimum(GregorianCalendar.MONTH);
        System.out.println("Actual Minimum, MONTH = " + min);

    }
}

Output

Actual Maximum, DAY_OF_MONTH = 30
Actual Maximum, MONTH = 11
Actual Minimum, DAY_OF_MONTH = 1
Actual Minimum, MONTH = 0

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

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

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/ca178d0280357a5fff33a91716acad6f25ed6390/BasicJava_2018/GregorianCalendarDemo_getActualMax_Min/?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