dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #34017
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17450: MathUtils, specified locale for double validation
------------------------------------------------------------
revno: 17450
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-11-12 11:19:24 +0100
message:
MathUtils, specified locale for double validation
modified:
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/MathUtils.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/MathUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/MathUtils.java 2014-11-03 00:24:32 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/MathUtils.java 2014-11-12 10:19:24 +0000
@@ -28,6 +28,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import static org.hisp.dhis.i18n.locale.LocaleManager.DHIS_STANDARD_LOCALE;
+
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.List;
@@ -50,7 +52,7 @@
private static DoubleValidator DOUBLE_VALIDATOR = new DoubleValidator();
private static IntegerValidator INT_VALIDATOR = new IntegerValidator();
- private static final double TOLERANCE = 0.01;
+ private static final double TOLERANCE = 0.01;
public static final String NUMERIC_REGEXP = "^(-?0|-?[1-9]\\d*)(\\.\\d+)?(E\\d+)?$";
public static final String NUMERIC_LENIENT_REGEXP = "^(-?[0-9]+)(\\.[0-9]+)?(E\\d+)?$";
@@ -317,7 +319,7 @@
*/
public static boolean isNumeric( String value )
{
- return value != null && DOUBLE_VALIDATOR.isValid( value ) && NUMERIC_PATTERN.matcher( value ).matches();
+ return value != null && DOUBLE_VALIDATOR.isValid( value, DHIS_STANDARD_LOCALE ) && NUMERIC_PATTERN.matcher( value ).matches();
}
/**
@@ -329,7 +331,7 @@
*/
public static boolean isNumericLenient( String value )
{
- return value != null && DOUBLE_VALIDATOR.isValid( value ) && NUMERIC_LENIENT_PATTERN.matcher( value ).matches();
+ return value != null && DOUBLE_VALIDATOR.isValid( value, DHIS_STANDARD_LOCALE ) && NUMERIC_LENIENT_PATTERN.matcher( value ).matches();
}
/**