Tuesday 3 July 2018

How to use getActualMaximum(int field) method of Java.util.calendar class


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

CalendarDemo.java

import java.util.Calendar;

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

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


        // get the maximum value that year field can have
        int maxYear = cal.getActualMaximum(Calendar.YEAR);
        System.out.println("Maximum year = " + maxYear);

        // get the maximum value that month field can have
        int maxMonth = cal.getActualMaximum(Calendar.MONTH);
        System.out.println("Maximum month = " + maxMonth);

    }

}

Output

Maximum year = 292278994
Maximum month = 11

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

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

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