Home » Java programming language

Java GregorianCalendar getLeastMaximum() Method with Example

GregorianCalendar Class getLeastMaximum() method: Here, we are going to learn about the getLeastMaximum() method of GregorianCalendar Class with its syntax and example.
Submitted by Preeti Jain, on February 15, 2020

GregorianCalendar Class getLeastMaximum() method

  • getLeastMaximum() method is available in java.util package.
  • getLeastMaximum() method is used to get the least maximum value of the specified calendar field (fi) in this GregorianCalendar object.
  • getLeastMaximum() method is a non-static method, it is accessible with class object only and if we try to access the method with class name then we will get an error.
  • getLeastMaximum() method does not throw an exception at the time of returning least maximum value that the given field can hold.


    public int getLeastMaximum(int fi);


  • int fi – represents the GregorianCalendar field (fi).

Return value:

The return type of this method is int, it returns the least maximum value of the given field (fi).


import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegexMatches {
    public static void main(String args[]) {

        // String to be scanned to find the pattern.
        String line = "This order was placed for QT3000! OK?";
        String pattern = "(.*)(\\d+)(.*)";

        // Create a Pattern object
        Pattern r = Pattern.compile(pattern);

        // Now create matcher object.
        Matcher m = r.matcher(line);
        if (m.find()) {
            System.out.println("Found value: " +;
            System.out.println("Found value: " +;
            System.out.println("Found value: " +;
        } else {
            System.out.println("NO MATCH");


Found value: This order was placed for QT3000! OK?
Found value: This order was placed for QT300
Found value: 0


Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© some rights reserved.