Java examples for Date Time:Legacy Date Format
Formatting and Parsing a Time for a Locale Using Default Formats
import java.text.DateFormat; import java.text.ParseException; import java.util.Date; import java.util.Locale; public class Main { public void main(String[] argv) { Locale locale = Locale.ITALIAN; Date date = new Date(); String s = DateFormat.getTimeInstance(DateFormat.SHORT, locale) .format(date);//from w w w . ja v a 2 s. c om System.out.println(s); s = DateFormat.getTimeInstance(DateFormat.MEDIUM, locale).format(date); System.out.println(s); s = DateFormat.getTimeInstance(DateFormat.LONG, locale).format(date); System.out.println(s); s = DateFormat.getTimeInstance(DateFormat.FULL, locale).format(date); System.out.println(s); s = DateFormat.getTimeInstance(DateFormat.DEFAULT, locale).format(date); System.out.println(s); try { date = DateFormat.getTimeInstance(DateFormat.DEFAULT, locale).parse("22.33.03"); } catch (ParseException e) { } } }