Today I will present how to Format Date with java.text.* package
Class java.text.SimpleDateFormat for example below
Date date=new Date();
System.out.println("No format :"+date);
java.text.SimpleDateFormat df= new java.text.SimpleDateFormat();
System.out.println("No pattern format :"+df.format(date));
df.applyPattern("dd/mm/yyyy");
System.out.println("dd/mm/yyyy format :"+df.format(date));
df.applyPattern("dd/mm/yyyy HH:mm:ss");
System.out.println("dd/mm/yyyy HH:mm:ss format :"+df.format(date));
Output for Java SimpleDateFormat
No format :Thu Apr 05 16:29:18 ICT 2012
No pattern format :5/4/2555, 16:29 น.
dd/mm/yyyy format :05/29/2555
dd/mm/yyyy HH:mm:ss format :05/29/2555 16:29:18