Scanner useLocale() method in Java with Examples Last Updated : 11 Oct, 2018 Comments Improve Suggest changes Like Article Like Report The useLocale() method of java.util.Scanner class sets this scanner's locale to the specified locale. Syntax: public Scanner useLocale(Locale locale) Parameters: The function accepts a mandatory parameter locale which specifies a string specifying the locale to use. Return Value: The function returns this modified scanner. Exceptions: If the radix is less than Character.MIN_RADIX or greater than Character.MAX_RADIX, then an IllegalArgumentException is thrown. Below programs illustrate the above function: Program 1: Java // Java program to illustrate the // Scanner useLocale() method in Java import java.util.*; public class GFG1 { public static void main(String[] argv) throws Exception { String s = "Geeksforgeeks has Scanner Class Methods"; // create a new scanner // with the specified String Object Scanner scanner = new Scanner(s); // print a line of the scanner System.out.println("Scanner String: \n" + scanner.nextLine()); // display the previous locale System.out.println("Current Lcoale: " + scanner.locale()); // change the locale of the scanner scanner.useLocale(Locale.ENGLISH); System.out.println("Changing Locale to ENGLISH"); // display the new locale System.out.println("Updated Locale: " + scanner.locale()); // close the scanner scanner.close(); } } Output: Scanner String: Geeksforgeeks has Scanner Class Methods Current Lcoale: en_US Changing Locale to ENGLISH Updated Locale: en Program 2: Java // Java program to illustrate the // Scanner useLocale() method in Java import java.util.*; public class GFG1 { public static void main(String[] argv) throws Exception { String s = "Geeksforgeeks 2018"; // create a new scanner // with the specified String Object Scanner scanner = new Scanner(s); // print a line of the scanner System.out.println("Scanner String: \n" + scanner.nextLine()); // display the previous locale System.out.println("Current Lcoale: " + scanner.locale()); // change the locale of the scanner scanner.useLocale(Locale.FRENCH); System.out.println("Changing Locale to FRENCH"); // display the new locale System.out.println("Updated Locale: " + scanner.locale()); // close the scanner scanner.close(); } } Output: Scanner String: Geeksforgeeks 2018 Current Lcoale: en_US Changing Locale to FRENCH Updated Locale: fr Reference: https://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html#useLocale(java.util.Locale) Comment More infoAdvertise with us Next Article Scanner useLocale() method in Java with Examples G gopaldave Follow Improve Article Tags : Java Java-Library Java - util package Practice Tags : Java Similar Reads Scanner useRadix() method in Java with Examples The useRadix(radix) method of java.util.Scanner class sets this scanner's default radix to the specified radix. A scanner's radix affects elements of its default number matching regular expressions. Syntax: public Scanner useRadix(int radix) Parameters: The function accepts a mandatory parameter rad 2 min read Scanner reset() method in Java with Examples The reset() method of java.util.Scanner class resets this scanner. On resetting a scanner, it discards all of its explicit state information which may have been changed by invocations of useDelimiter(java.util.regex.Pattern), useLocale(java.util.Locale), or useRadix(int). Syntax: public Scanner rese 2 min read Scanner radix() method in Java with Examples The radix() method of java.util.Scanner class returns this scanner's default radix. Syntax: public int radix() Return Value: This function returns the default radix of this scanner. Below programs illustrate the above function: Program 1: Java // Java program to illustrate the // radix() method of S 2 min read Scanner locale() method in Java with Examples The locale() method of java.util.Scanner class returns this scanner's locale. Syntax: public Locale locale() Parameters: The function does not accepts any parameter. Return Value: This function returns this scanner's locale Below programs illustrate the above function: Program 1: Java // Java progra 1 min read OffsetTime toLocalTime() method in Java with examples The toLocalTime() method of OffsetTime class in Java gets the LocalTime part of this date-time. Syntax : public LocalTime toLocalTime() Parameter: This method does not accepts any parameter. Return Value: It returns a LocalTime with the same hour, minute, second and nanosecond as this date-time. Bel 1 min read Like