SimpleDateFormat applyPattern() Method in Java with Examples
The applyPattern() Method of SimpleDateFormat class is used to set a given defined pattern to the Date Format. It simply converts a particular date and time to a specific format as defined by the user for eg., dd/ MM/ yyyy HH:mm Z or MM/ dd/ yyyy HH:mm Z.
public void applyPattern(String pattern)
Parameters: The method takes one parameter pattern of String type and refers to the new date and time pattern for this date format.
Return Value: The method returns void type.
Below programs illustrate the working of applyPattern() Method of SimpleDateFormat:
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.
The Current Date: 29/ 01/ 2019 07:22 +0000 Applied Pattern: dd/ MM/ yyyy HH:mm Z
The Current Date: 01/ 29/ 2019 07:22 +0000 Applied Pattern: MM/ dd/ yyyy HH:mm Z