Format date with MM/dd/yy in Java
Description
The following code shows how to format date with MM/dd/yy.
Example
// w w w .java 2s . c o m
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Main {
public static void main(String[] argv) throws Exception {
Date date = new Date();
Format formatter = new SimpleDateFormat("MM/dd/yy");
String s = formatter.format(date);
System.out.println(s);
}
}
The code above generates the following result.