Find the current date format in Java
Description
The following code shows how to find the current date format.
Example
//from w ww . j a va 2 s .c om
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Locale;
public class Main {
public static void main(String args[]) {
SimpleDateFormat df = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT);
System.out.println("The short date format is " + df.toPattern());
Locale loc = Locale.ITALY;
df = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT, loc);
System.out.println("The short date format is " + df.toPattern());
}
}
The code above generates the following result.