View | Details | Raw Unified | Return to bug 50271
Collapse All | Expand All

(-)src/java/org/apache/poi/ss/usermodel/DataFormatter.java (+13 lines)
Lines 91-96 Link Here
91
       		"(\\[COLOR\\s*\\d\\])|(\\[COLOR\\s*[0-5]\\d\\])", Pattern.CASE_INSENSITIVE);
91
       		"(\\[COLOR\\s*\\d\\])|(\\[COLOR\\s*[0-5]\\d\\])", Pattern.CASE_INSENSITIVE);
92
    
92
    
93
    /**
93
    /**
94
     * The locale used for formating values.
95
     */
96
    private final Locale currentLocale;
97
    
98
    /**
94
     * The decimal symbols of the locale used for formatting values.
99
     * The decimal symbols of the locale used for formatting values.
95
     */
100
     */
96
    private final DecimalFormatSymbols decimalSymbols;
101
    private final DecimalFormatSymbols decimalSymbols;
Lines 126-131 Link Here
126
     * Creates a formatter using the given locale.
131
     * Creates a formatter using the given locale.
127
     */
132
     */
128
    public DataFormatter(Locale locale) {
133
    public DataFormatter(Locale locale) {
134
    	currentLocale = locale;
129
        dateSymbols = new DateFormatSymbols(locale);
135
        dateSymbols = new DateFormatSymbols(locale);
130
        decimalSymbols = new DecimalFormatSymbols(locale);
136
        decimalSymbols = new DecimalFormatSymbols(locale);
131
        generalWholeNumFormat = new DecimalFormat("#", decimalSymbols);
137
        generalWholeNumFormat = new DecimalFormat("#", decimalSymbols);
Lines 170-175 Link Here
170
        }
176
        }
171
177
172
        int formatIndex = cell.getCellStyle().getDataFormat();
178
        int formatIndex = cell.getCellStyle().getDataFormat();
179
        
180
        // when formatIndex equals 0xe, formatCode is empty. We should handle this case separately
181
        // so that the locale can be applied.
182
        if (formatIndex == 0xe) {
183
        	return DateFormat.getDateInstance(DateFormat.SHORT, currentLocale); 
184
        }
185
        
173
        String formatStr = cell.getCellStyle().getDataFormatString();
186
        String formatStr = cell.getCellStyle().getDataFormatString();
174
        if(formatStr == null || formatStr.trim().length() == 0) {
187
        if(formatStr == null || formatStr.trim().length() == 0) {
175
            return null;
188
            return null;

Return to bug 50271