List of usage examples for java.text DateFormat LONG
int LONG
To view the source code for java.text DateFormat LONG.
Click Source Link
From source file:Test.java
public static void main(String[] args) { Locale locale = Locale.getDefault(); Calendar calendar = Calendar.getInstance(); calendar.setWeekDate(2012, 16, 3);//from w ww. j a va 2s. c o m System.out.println( DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(calendar.getTime())); System.out.println("" + locale.getDisplayLanguage()); Locale.setDefault(Locale.Category.FORMAT, Locale.JAPANESE); Locale.setDefault(Locale.Category.DISPLAY, Locale.GERMAN); System.out.println( DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(calendar.getTime())); System.out.println("" + locale.getDisplayLanguage()); }
From source file:TimeFormatDemo.java
public static void main(String args[]) { Date date = new Date(); DateFormat df;/*from ww w .j a v a 2 s .c o m*/ df = DateFormat.getTimeInstance(DateFormat.SHORT, Locale.JAPAN); System.out.println("Japan: " + df.format(date)); df = DateFormat.getTimeInstance(DateFormat.LONG, Locale.UK); System.out.println("United Kingdom: " + df.format(date)); df = DateFormat.getTimeInstance(DateFormat.FULL, Locale.CANADA); System.out.println("Canada: " + df.format(date)); }
From source file:Main.java
public static void main(String[] args) { Date date = new Date(); String strDate = DateFormat.getDateInstance(DateFormat.DEFAULT).format(date); System.out.println(strDate);/*from ww w . jav a 2s . c om*/ strDate = DateFormat.getDateInstance(DateFormat.FULL).format(date); System.out.println(strDate); strDate = DateFormat.getDateInstance(DateFormat.LONG).format(date); System.out.println(strDate); strDate = DateFormat.getDateInstance(DateFormat.SHORT).format(date); System.out.println(strDate); }
From source file:Test.java
public static void main(String[] args) { Calendar calendar = Calendar.getInstance(); if (calendar.isWeekDateSupported()) { System.out.println("Number of weeks in this year: " + calendar.getWeeksInWeekYear()); System.out.println("Current week number: " + calendar.get(Calendar.WEEK_OF_YEAR)); }/*from w ww . j a va2 s . c o m*/ calendar.setWeekDate(2012, 16, 3); System.out.println( DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(calendar.getTime())); }
From source file:Main.java
public static void main(String[] args) { Date date = new Date(); // Format date in a short format String today = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(date); System.out.println("Today " + today); // Format date in a medium format today = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM).format(date); System.out.println("Today " + today); // Format date in a long format today = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(date); System.out.println("Today " + today); }
From source file:MainClass.java
public static void main(String args[]) { Date date = new Date(); DateFormat df;/*from ww w . j a v a 2 s .c om*/ df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.JAPAN); System.out.println("Japan: " + df.format(date)); df = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.KOREA); System.out.println("Korea: " + df.format(date)); df = DateFormat.getDateInstance(DateFormat.LONG, Locale.UK); System.out.println("United Kingdom: " + df.format(date)); df = DateFormat.getDateInstance(DateFormat.FULL, Locale.US); System.out.println("United States: " + df.format(date)); }
From source file:Test.java
public static void main(String[] args) { Calendar calendar = Calendar.getInstance(); calendar.setWeekDate(2012, 16, 3);//from w w w . j a va2s . com Builder builder = new Builder(); builder.setLanguage("hy"); builder.setScript("Latn"); builder.setRegion("IT"); builder.setVariant("arevela"); Locale locale = builder.build(); Locale.setDefault(locale); System.out.println( DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(calendar.getTime())); System.out.println("" + locale.getDisplayLanguage()); builder.setLanguage("zh"); builder.setScript("Hans"); builder.setRegion("CN"); locale = builder.build(); Locale.setDefault(locale); System.out.println( DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(calendar.getTime())); System.out.println("" + locale.getDisplayLanguage()); }
From source file:MainClass.java
public static void main(String[] args) { Date today = new Date(); Locale[] locales = { Locale.US, Locale.UK, Locale.GERMANY, Locale.FRANCE }; int[] styles = { DateFormat.FULL, DateFormat.LONG, DateFormat.MEDIUM, DateFormat.SHORT }; DateFormat fmt;//from ww w.j a va 2 s. c o m String[] styleText = { "FULL", "LONG", "MEDIUM", "SHORT" }; // Output the date for each local in four styles for (int i = 0; i < locales.length; i++) { System.out.println("\nThe Date for " + locales[i].getDisplayCountry() + ":"); for (int j = 0; j < styles.length; j++) { fmt = DateFormat.getDateInstance(styles[j], locales[i]); System.out.println("\tIn " + styleText[j] + " is " + fmt.format(today)); } } }
From source file:Main.java
public static String getPrettyDateTime(Calendar date) { DateFormat dateTimeFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT); return dateTimeFormat.format(date.getTime()); }
From source file:Main.java
public static String getPrettyDate(int year, int month, int day) { Calendar c = new GregorianCalendar(year, month, day); DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.LONG); return dateFormat.format(c.getTime()); }