Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/common/AbstractParser.java @ 8989:2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
author | mschaefer |
---|---|
date | Mon, 09 Apr 2018 09:07:00 +0200 |
parents | 50416a0df385 |
children | c43d8c1a4455 |
comparison
equal
deleted
inserted
replaced
8988:ae76f618d990 | 8989:2693bfaf503d |
---|---|
14 import java.io.FileInputStream; | 14 import java.io.FileInputStream; |
15 import java.io.FilenameFilter; | 15 import java.io.FilenameFilter; |
16 import java.io.IOException; | 16 import java.io.IOException; |
17 import java.io.InputStreamReader; | 17 import java.io.InputStreamReader; |
18 import java.io.LineNumberReader; | 18 import java.io.LineNumberReader; |
19 import java.math.BigDecimal; | |
19 import java.text.NumberFormat; | 20 import java.text.NumberFormat; |
20 import java.text.ParseException; | 21 import java.text.ParseException; |
21 import java.util.ArrayList; | 22 import java.util.ArrayList; |
22 import java.util.List; | 23 import java.util.List; |
23 import java.util.Locale; | 24 import java.util.Locale; |
260 public static Number parseDouble(final String text) throws ParseException { | 261 public static Number parseDouble(final String text) throws ParseException { |
261 return numberFormat.parse(text.replace(',', '.')); | 262 return numberFormat.parse(text.replace(',', '.')); |
262 } | 263 } |
263 | 264 |
264 /** | 265 /** |
266 * Parses a number string as a BigDecimal, replacing a comma with a dot first | |
267 */ | |
268 public static BigDecimal parseDecimal(final String text) throws NumberFormatException { | |
269 return new BigDecimal(text.replace(',', '.')); | |
270 } | |
271 | |
272 /** | |
265 * Gets the class's logger | 273 * Gets the class's logger |
266 */ | 274 */ |
267 protected abstract Logger getLog(); | 275 protected abstract Logger getLog(); |
268 | 276 |
269 /** | 277 /** |