comparison backend/src/main/java/org/dive4elements/river/importer/parsers/WaterlevelParser.java @ 8991:c43d8c1a4455

Parse via decimalformat instead of bigdecimal constructor (to cope with strings with chars after the actual number)
author mschaefer
date Tue, 10 Apr 2018 16:43:32 +0200
parents 2693bfaf503d
children
comparison
equal deleted inserted replaced
8990:07dcedddf839 8991:c43d8c1a4455
10 10
11 import java.io.File; 11 import java.io.File;
12 import java.io.IOException; 12 import java.io.IOException;
13 import java.math.BigDecimal; 13 import java.math.BigDecimal;
14 import java.text.NumberFormat; 14 import java.text.NumberFormat;
15 import java.text.ParseException;
15 import java.util.ArrayList; 16 import java.util.ArrayList;
16 import java.util.List; 17 import java.util.List;
17 import java.util.regex.Matcher; 18 import java.util.regex.Matcher;
18 import java.util.regex.Pattern; 19 import java.util.regex.Pattern;
19 20
193 194
194 log.debug("Found new Q range: Q=" + valueStr); 195 log.debug("Found new Q range: Q=" + valueStr);
195 196
196 return true; 197 return true;
197 } 198 }
198 catch (final NumberFormatException pe) { 199 catch (final ParseException pe) {
199 log.warn("Unparseable Q range: '" + line + "'"); 200 log.warn("Unparseable Q range: '" + line + "'");
200 } 201 }
201 } 202 }
202 203
203 return false; 204 return false;
221 222
222 if (this.currentRange.getA() == null) { 223 if (this.currentRange.getA() == null) {
223 this.currentRange.setA(station); 224 this.currentRange.setA(station);
224 } 225 }
225 } 226 }
226 catch (final NumberFormatException pe) { 227 catch (final ParseException pe) {
227 log.warn("Unparseable number in data row: " + line); 228 log.warn("Unparseable number in data row: " + line);
228 } 229 }
229 } 230 }
230 } 231 }
231 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 232 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org