Wednesday, 16 January 2019

How to use toPattern() method of java.text.SimpleDateFormat class

Click here to watch on Youtube:

import java.text.DateFormat;
import java.text.SimpleDateFormat;

public class SimpleDateFormatDemo
    public static void main(String[] args)

        SimpleDateFormat df = (SimpleDateFormat) DateFormat.getDateInstance();

         * Returns:a pattern string describing this date format.

        String strPattern = df.toPattern();

        df = (SimpleDateFormat) DateFormat.getDateTimeInstance();

        strPattern = df.toPattern();



MMM d, yyyy
MMM d, yyyy h:mm:ss a

Click the below link to download the code:

Github Link:

Bitbucket Link:

See also:
  • All JavaEE Videos Playlist
  • All JavaEE Videos
  • All JAVA EE Links
  • Spring Tutorial
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial
  • Cooking Tutorial
  • Google+ Followers

    Google+ Badge