Use SimpleDateFormat to format date as 02/06/2005 - Java Date Time

Java examples for Date Time:SimpleDateFormat

Description

Use SimpleDateFormat to format date as 02/06/2005

Demo Code


 
import java.text.SimpleDateFormat;
import java.util.Date;
 
public class Main {
 
  public static void main(String args[]){
      Date date = new Date();
      String DATE_FORMAT = "MM/dd/yyyy";
      SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
     /*w w w.  j a va  2 s  .  c  o m*/
      System.out.println("Today is " + sdf.format(date) );
  }
}

Result


Related Tutorials