Java Date Format with SimpleDateFormat
You can use java.text.SimpleDateFormat to farmat Date
For example in below
For example in 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));
Out put when run this code
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
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