List of usage examples for java.text DateFormatSymbols getMonths
public String[] getMonths()
From source file:Main.java
public static void main(String[] args) { List list = new LinkedList(); DateFormatSymbols dfs = new DateFormatSymbols(); String[] months = dfs.getMonths(); for (int i = 0; i < months.length; i++) { String month = months[i]; list.add(month);/*from w w w .ja v a 2 s . c om*/ } Collections.sort(list); System.out.println("Month Names = " + list); int index = Collections.binarySearch(list, "October"); if (index > 0) { System.out.println("Found at index = " + index); String month = (String) list.get(index); System.out.println("Month = " + month); } }
From source file:OysterMonths.java
public static void main(String[] args) { OysterMonths om = new OysterMonths(); DateFormatSymbols dfs = new DateFormatSymbols(); String[] monthArray = dfs.getMonths(); Collection<String> months = Arrays.asList(monthArray); om.safeMonths = om.filter(months);//from w ww. j a v a2s .c o m System.out.println("The following months are safe for oysters:"); System.out.println(om.safeMonths); }
From source file:Main.java
public static String getMonth(String monthNo) { DateFormatSymbols dfs = new DateFormatSymbols(); String[] months = dfs.getMonths(); return months[Integer.parseInt(monthNo) - 1]; }
From source file:Main.java
public static String getDayAndMonthFromDateString(String date) { java.util.Calendar calendar = getCalendarFromStringDate(date); System.out.println("Date ->" + date); DateFormatSymbols symbols = new DateFormatSymbols(new Locale("es", "ES")); String[] monthNames = symbols.getMonths(); return calendar.get(java.util.Calendar.DAY_OF_MONTH) + " DE " + monthNames[calendar.get(java.util.Calendar.MONTH)]; }
From source file:Main.java
/** * Convert 2 to February/*from w w w . j av a2 s. c o m*/ * * @param month * @param locale * @return */ public static String formatMonth(int month, Locale locale) { DateFormatSymbols symbols = new DateFormatSymbols(locale); String[] monthNames = symbols.getMonths(); return monthNames[month - 1]; }
From source file:Main.java
/** * Convert "Friday X Month Year" to "YYYY-MM-DD" * /*from w w w . java2 s. c o m*/ * @param Date_STR * @param conf * @return */ public static String dateSTR2Num(String Date_STR, Configuration conf) { String[] DateARR = Date_STR.split(" "); String DayNo = DateARR[1]; String YearSTR = DateARR[3]; //----- Month problem ------ String MonthSTR = DateARR[2]; DateFormatSymbols symbols = new DateFormatSymbols(conf.locale); String[] monthNames = symbols.getMonths(); int iMonth = 0; for (int i = 0; i < monthNames.length; i++) if (MonthSTR.equals(monthNames[i])) iMonth = i; String MonthNo = Integer.toString(iMonth + 1); if (MonthNo.length() < 2) MonthNo = "0" + MonthNo; return YearSTR + "-" + MonthNo + "-" + DayNo; }
From source file:com.siphyc.utils.Utilities.java
public static String getMonthForInt(int num) { String month = "wrong"; DateFormatSymbols dfs = new DateFormatSymbols(); String[] months = dfs.getMonths(); if (num >= 0 && num <= 11) { month = months[num];/*from ww w . j a v a2 s. c o m*/ } return month; }
From source file:org.toobsframework.transformpipeline.xslExtentions.DateHelper.java
public static String getMonthStringFromNumber(String monthNumber) { int monthInt = -1; try {//from w ww. java2 s . c om monthInt = Integer.parseInt(monthNumber); } catch (NumberFormatException e) { return ""; } if (monthInt < 1 || monthInt > 12) { return ""; } DateFormatSymbols dfs = new DateFormatSymbols(); /* String[] month = {"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; */ return dfs.getMonths()[monthInt - 1]; //month[monthInt]; }
From source file:de.undercouch.citeproc.bibtex.DateParser.java
/** * Retrieves and caches a list of month names for a given locale * @param locale the locale//from w w w . j av a 2 s . co m * @return the list of month names (short and long). All names are * converted to upper case */ private static Map<String, Integer> getMonthNames(Locale locale) { Map<String, Integer> r = MONTH_NAMES_CACHE.get(locale); if (r == null) { DateFormatSymbols symbols = DateFormatSymbols.getInstance(locale); r = new HashMap<String, Integer>(24); //insert long month names String[] months = symbols.getMonths(); for (int i = 0; i < months.length; ++i) { String m = months[i]; if (!m.isEmpty()) { r.put(m.toUpperCase(), i + 1); } } //insert short month names String[] shortMonths = symbols.getShortMonths(); for (int i = 0; i < shortMonths.length; ++i) { String m = shortMonths[i]; if (!m.isEmpty()) { r.put(m.toUpperCase(), i + 1); } } MONTH_NAMES_CACHE.put(locale, r); } return r; }
From source file:nl.tricode.magnolia.blogs.templates.BlogRenderableDefinition.java
public static String getMonthName(String month) { int monthNr = Integer.parseInt(month); Locale locale = new Locale(DEFAULT_LANGUAGE); DateFormatSymbols symbols = new DateFormatSymbols(locale); String[] monthNames = symbols.getMonths(); return monthNames[monthNr - 1]; }