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.

Syntax:

    public int getLeastMaximum(int fi);

Parameter(s):

  • 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).

Example:

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: " + m.group(0));
            System.out.println("Found value: " + m.group(1));
            System.out.println("Found value: " + m.group(2));
        } else {
            System.out.println("NO MATCH");
        }
    }
}

Output

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


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.