Wednesday, 16 January 2019

How to use toLocalizedPattern() method of java.text.SimpleDateFormat class | Dateformatter in java


Click here to watch on Youtube: 
https://www.youtube.com/watch?v=JrGSwX8AwEA&list=UUhwKlOVR041tngjerWxVccw

SimpleDateFormatDemo.java

import java.text.SimpleDateFormat;
import java.util.Date;

public class SimpleDateFormatDemo
{
    public static void main(String[] args)
    {
        Date date =  new Date();
        System.out.println("date = "+date);
               
        SimpleDateFormat formatter = new SimpleDateFormat();
       
        /*
         * Returns:a localized pattern string describing this date format.
         */

        String strPattern = formatter.toLocalizedPattern();
        System.out.println("Pattern =  "+strPattern);
       
        String strDate = formatter.format(date);
        System.out.println("Formatted Date = " + strDate);
    }

}

Output:

date = Thu Jan 10 10:08:20 IST 2019
Pattern =  M/d/yy h:mm a
Formatted Date = 1/10/19 10:08 AM

Click the below link to download the code:
https://sites.google.com/site/javaspringram2019/java_spring_2019/SimpleDateFormatDemo_toLocalizedPattern.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java_Spring_2019/tree/master/Java_2019/SimpleDateFormatDemo_toLocalizedPattern

Bitbucket Link:
https://bitbucket.org/ramram43210/java_spring_2019/src/4327965661b34e0cc17880946800be5f5d73f2dd/Java_2019/SimpleDateFormatDemo_toLocalizedPattern/?at=master

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
  • No comments:

    Post a Comment