SimpleDateFormat toLocalizedPattern() Method in Java with Examples
The toLocalizedPattern() Method of SimpleDateFormat class is used to return a localized pattern formatted string describing this date format. In other words a particular date is converted to a local pattern such as M/d/yy h:mm a.
Syntax:
public String toLocalizedPattern()
Parameters: The method does not take any parameter.
Return Value: The method returns localized pattern String of the Date Formatter.
Below programs illustrate the working of toLocalizedPattern() Method of SimpleDateFormat:
Example 1:
// Java code to illustrate // toLocalizedPattern() method import java.text.*; import java.util.Calendar; public class SimpleDateFormat_Demo { public static void main(String[] args) throws InterruptedException { // Initializing date Formatter SimpleDateFormat SDFormat = new SimpleDateFormat(); // Initializing the calender Object Calendar cal = Calendar.getInstance(); // Displaying the date System.out.println("Date: " + SDFormat.format( cal.getTime())); // Use of toLocalizedPattern() method System.out.println("In localized pattern: " + SDFormat .toLocalizedPattern()); } } |
Date: 1/29/19 8:02 AM In localized pattern: M/d/yy h:mm a
Example 2:
// Java code to illustrate // toLocalizedPattern() method import java.text.*; import java.util.Calendar; public class SimpleDateFormat_Demo { public static void main(String[] args) throws InterruptedException { // Initializing date Formatter SimpleDateFormat SDFormat = new SimpleDateFormat(); // Initializing the calender Object Calendar cal = Calendar.getInstance(); // Displaying the date System.out.println("Date: " + SDFormat .format( cal.getTime())); // Use of toLocalizedPattern() method System.out.println("In localized pattern: " + SDFormat .toLocalizedPattern()); } } |
Date: 1/29/19 12:46 PM In localized pattern: M/d/yy h:mm a
Recommended Posts:
- SimpleDateFormat applyLocalizedPattern() Method in Java with Examples
- SimpleDateFormat clone() Method in Java with Examples
- SimpleDateFormat setDateFormatSymbols() Method in Java with Examples
- SimpleDateFormat hashCode() Method in Java with Examples
- SimpleDateFormat get2DigitYearStart() Method in Java with Examples
- SimpleDateFormat applyPattern() Method in Java with Examples
- SimpleDateFormat parse() Method in Java with Examples
- SimpleDateFormat set2DigitYearStart() Method in Java with Examples
- SimpleDateFormat equals() Method in Java with Examples
- SimpleDateFormat getDateFormatSymbols() Method in Java with Examples
- SimpleDateFormat toPattern() Method in Java with Examples
- SimpleDateFormat format() Method in Java with Examples
- DecimalFormat toLocalizedPattern() method in Java
- Java SimpleDateFormat | Set 1
- Java SimpleDateFormat | Set 2
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

