Java 类org.apache.poi.hssf.usermodel.HSSFDataFormatter 实例源码

项目:data-prep    文件:XlsUtils.java   
/**
 * Return the numeric value.
 *
 * @param cell the cell to extract the value from.
 * @return the numeric value from the cell.
 */
private static String getNumericValue(Cell cell, CellValue cellValue, boolean fromFormula) {
    // Date is typed as numeric
    if (HSSFDateUtil.isCellDateFormatted(cell)) { // TODO configurable??
        DateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy", Locale.ENGLISH);
        return sdf.format(cell.getDateCellValue());
    }
    // Numeric type (use data formatter to get number format right)
    DataFormatter formatter = new HSSFDataFormatter(Locale.ENGLISH);

    if (cellValue == null) {
        return formatter.formatCellValue(cell);
    }

    return fromFormula ? cellValue.formatAsString() : formatter.formatCellValue(cell);
}
项目:UtilsMaven    文件:FormatTrackingHSSFListenerPlus.java   
/**
 * Creates a format tracking wrapper around the given listener, using
 * the given locale for the formats.
 *
 * @param childListener the listener to be wrapped
 * @param locale        the locale for the formats
 */
public FormatTrackingHSSFListenerPlus(
        HSSFListener childListener, Locale locale) {
    _childListener = childListener;
    _formatter = new HSSFDataFormatter(locale);
    _defaultFormat = NumberFormat.getInstance(locale);
}