Code example for BigDecimal

Methods: movePointRight, setScale, subtract

0
        calendar.add(Calendar.MINUTE, addition ? minutes : 0 - minutes);
        calendar.add(Calendar.SECOND, (seconds == null)
                ? 0 : addition ? seconds.intValue() : 0 - seconds.intValue());
 
        if (seconds != null) {
            BigDecimal fraction = seconds.subtract(seconds.setScale(0, BigDecimal.ROUND_DOWN));
            int millisec = fraction.movePointRight(3).intValue();
            calendar.add(Calendar.MILLISECOND, addition ? millisec : 0 - millisec);
        } 
    } 
 
    private static int parseInt(String value) {
        if (value == null) {
            return 0; 
        } else { 
            return Integer.parseInt(value.substring(0, value.length() - 1));
        } 
    } 
 
    public static boolean isValidExpression(String exp) {
        String tExp = exp;