Code example for DecimalFormat

Methods: parse, setDecimalFormatSymbols

0
 
    public static int parseGetal(String getal) throws ParseException {
        DecimalFormatSymbols dfs = new DecimalFormatSymbols();
        dfs.setGroupingSeparator('.');
        dfs.setDecimalSeparator(',');
        DecimalFormat decimalFormat = new DecimalFormat();
        decimalFormat.setDecimalFormatSymbols(dfs);
        Number number = decimalFormat.parse(getal);
        return number.intValue();
    } 
 
    public static int numberOfDaysPreviousMonth() { 
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.MONTH, -1);
        return numberOfDaysInMonth(cal);
    } 
 
    public static int numberOfDaysThisMonth() { 
        Calendar cal = Calendar.getInstance();
        return numberOfDaysInMonth(cal);
    }