List of usage examples for org.apache.commons.beanutils.locale LocaleConvertUtils convert
public static Object convert(String[] values, Class clazz, String pattern)
Convert an array of specified values to an array of objects of the specified class (if possible) using the convertion pattern.
For more details see LocaleConvertUtilsBean
From source file:org.sipfoundry.sipxconfig.acd.stats.AcdHistoricalStatsImpl.java
public void dumpReport(Writer writer, List<Map<String, Object>> reportData, Locale locale) throws IOException { // nothing ACD specific here, could be reused if (reportData.size() == 0) { return;/*from w w w . j a v a 2 s .c o m*/ } // column names CsvWriter csv = new CsvWriter(writer); Map<String, Object> row0 = reportData.get(0); csv.write(row0.keySet().toArray(new String[0]), false); // rows for (Map<String, Object> record : reportData) { Object[] recordData = record.values().toArray(); String[] recordDataStrings = new String[recordData.length]; for (int i = 0; i < recordData.length; i++) { // convert date field (if present) to appropriate locale if (recordData[i] instanceof Date) { recordDataStrings[i] = LocaleConvertUtils.convert(recordData[i], locale, m_exportDatePattern); } else { recordDataStrings[i] = String.valueOf(recordData[i]); } } csv.write(recordDataStrings, false); } }
From source file:org.sipfoundry.sipxconfig.acd.stats.historical.AcdHistoricalStatsImpl.java
public void dumpReport(Writer writer, List<Map<String, Object>> reportData, Locale locale) throws IOException { // nothing ACD specific here, could be reused if (reportData.size() == 0) { return;/*w ww . j av a 2s. c om*/ } // column names SimpleCsvWriter csv = new SimpleCsvWriter(writer, false); Map<String, Object> row0 = reportData.get(0); csv.write(row0.keySet().toArray(new String[0])); // rows for (Map<String, Object> record : reportData) { Object[] recordData = record.values().toArray(); String[] recordDataStrings = new String[recordData.length]; for (int i = 0; i < recordData.length; i++) { // convert date field (if present) to appropriate locale if (recordData[i] instanceof Date) { recordDataStrings[i] = LocaleConvertUtils.convert(recordData[i], locale, m_exportDatePattern); } else { recordDataStrings[i] = String.valueOf(recordData[i]); } } csv.write(recordDataStrings); } }