File tree 2 files changed +10
-4
lines changed
src/main/java/com/github/sidhant92/boolparser/datatype 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change 1
1
package com .github .sidhant92 .boolparser .datatype ;
2
2
3
+ import java .math .BigDecimal ;
3
4
import java .util .Optional ;
4
5
import com .github .sidhant92 .boolparser .constant .DataType ;
5
6
@@ -22,7 +23,8 @@ public boolean isValid(final Object value) {
22
23
boolean isValid = super .defaultIsValid (value );
23
24
if (!isValid ) {
24
25
try {
25
- Integer .parseInt (value .toString ());
26
+ BigDecimal number = new BigDecimal (value .toString ());
27
+ Integer .parseInt (number .stripTrailingZeros ().toPlainString ());
26
28
return true ;
27
29
} catch (Exception ex ) {
28
30
return false ;
@@ -46,7 +48,8 @@ public Optional<Integer> getValue(Object value) {
46
48
return result ;
47
49
}
48
50
try {
49
- return Optional .of (Integer .parseInt (value .toString ()));
51
+ BigDecimal number = new BigDecimal (value .toString ());
52
+ return Optional .of (Integer .parseInt (number .stripTrailingZeros ().toPlainString ()));
50
53
} catch (final Exception ignored ) {
51
54
}
52
55
return Optional .empty ();
Original file line number Diff line number Diff line change 1
1
package com .github .sidhant92 .boolparser .datatype ;
2
2
3
+ import java .math .BigDecimal ;
3
4
import java .util .Optional ;
4
5
import com .github .sidhant92 .boolparser .constant .DataType ;
5
6
@@ -22,7 +23,8 @@ public boolean isValid(final Object value) {
22
23
boolean isValid = super .defaultIsValid (value );
23
24
if (!isValid ) {
24
25
try {
25
- Long .parseLong (value .toString ());
26
+ BigDecimal number = new BigDecimal (value .toString ());
27
+ Long .parseLong (number .stripTrailingZeros ().toPlainString ());
26
28
return true ;
27
29
} catch (Exception ex ) {
28
30
return false ;
@@ -46,7 +48,8 @@ public Optional<Long> getValue(Object value) {
46
48
return result ;
47
49
}
48
50
try {
49
- return Optional .of (Long .parseLong (value .toString ()));
51
+ BigDecimal number = new BigDecimal (value .toString ());
52
+ return Optional .of (Long .parseLong (number .stripTrailingZeros ().toPlainString ()));
50
53
} catch (final Exception ignored ) {
51
54
}
52
55
return Optional .empty ();
You can’t perform that action at this time.
0 commit comments