List of usage examples for java.util Calendar getDisplayName
public String getDisplayName(int field, int style, Locale locale)
field
value in the given style
and locale
. From source file:Main.java
public static void main(String[] args) { Calendar now = Calendar.getInstance(); Locale locale = Locale.getDefault(); String n = now.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.ALL_STYLES, locale); System.out.printf(n);/*ww w . j a va2 s . c o m*/ }
From source file:Main.java
public static void main(String[] args) { Calendar now = Calendar.getInstance(); Locale locale = Locale.getDefault(); String n = now.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, locale); System.out.printf(n);/*from w w w . j a v a2s .c o m*/ }
From source file:Main.java
public static void main(String[] args) { Calendar now = Calendar.getInstance(); Locale locale = Locale.getDefault(); String n = now.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, locale); System.out.printf(n);/* w w w . j av a2 s .c o m*/ }
From source file:DisplayNames.java
public static void main(String args[]) { Calendar now = Calendar.getInstance(); // Locale locale = Locale.getDefault(); Locale locale = Locale.ITALIAN; Map<String, Integer> names = now.getDisplayNames(Calendar.DAY_OF_WEEK, Calendar.LONG, locale); System.out.println(names);/*from w w w . j av a 2s. c o m*/ String name = now.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, locale); System.out.printf("Today is a %s.%n", name); }
From source file:Main.java
public static String getShortMonthYearDisplay(Calendar cal) { return cal.getDisplayName(Calendar.MONTH, Calendar.SHORT, Locale.US) + " " + cal.get(Calendar.YEAR); }
From source file:Main.java
public static String getShortDateDisplay(Calendar cal) { return cal.getDisplayName(Calendar.MONTH, Calendar.SHORT, Locale.US) + " " + cal.get(Calendar.DATE); }
From source file:Main.java
public static String getDateDisplay(Calendar cal) { return cal.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.US) + " " + cal.get(Calendar.DATE) + ", " + cal.get(Calendar.YEAR); }
From source file:Main.java
public static String getWeekDay(int position) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_WEEK, position + 1); return calendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, Locale.getDefault()); }
From source file:Main.java
public static String getMonthStringFromDate(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date);/*from w w w . ja v a 2 s . co m*/ StringBuilder sb = new StringBuilder(); sb.append(calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.US)).append(", ") .append(calendar.get(Calendar.YEAR)); return sb.toString(); }
From source file:Main.java
/** * Returns the month and release date of the movie * * @param releaseDate release date in yyyy-MM-dd format * @return month and year//w w w . j a va 2 s . com */ @NonNull public static String getDisplayReleaseDate(String releaseDate) { if (TextUtils.isEmpty(releaseDate)) { return ""; } try { Calendar calendar = Calendar.getInstance(); calendar.setTime(DATE_FORMAT.parse(releaseDate)); return calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.ENGLISH) + " " + calendar.get(Calendar.YEAR); } catch (ParseException e) { return ""; } }