Package de.xanders.common.exception

Examples of de.xanders.common.exception.FormattingException


            BigDecimal bigDecValue = (BigDecimal) value;
            bigDecValue = bigDecValue.setScale(CURRENCY_SCALE,
                    BigDecimal.ROUND_HALF_UP);
            stringValue = NumberFormat.getInstance().format(bigDecValue.doubleValue());
        } catch (IllegalArgumentException iae) {
            throw new FormattingException("Unable to format " + value +
                "as a currency value", iae);
        }

        return stringValue;
    }
View Full Code Here


        if (mode == OBJECT_TO_STRING) {
            return format(target);
        } else if (mode == STRING_TO_OBJECT) {
            return unformat((String) target);
        } else {
            throw new FormattingException("Invalid mode: " + String.valueOf(mode));
        }
    }
View Full Code Here

        try {
            DecimalFormat formatter = new DecimalFormat(PERCENTAGE_FORMAT);
            Number parsedNumber = formatter.parse(target.trim());
            value = new BigDecimal(parsedNumber.doubleValue());
        } catch (NumberFormatException nfe) {
            throw new FormattingException(errorMsg, nfe);
        } catch (ParseException pe) {
            throw new FormattingException(errorMsg, pe);
        }

        return value;
    }
View Full Code Here

        SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT);
        formatter.setLenient(false);
        date = formatter.parse(target, new ParsePosition(0));

        if (date == null) {
            throw new FormattingException(errorMsg);
        }

        return date;
    }
View Full Code Here

        try {
            DecimalFormat formatter = new DecimalFormat(PERCENTAGE_FORMAT);
            Number parsedNumber = formatter.parse(target.trim());
            value = new BigDecimal(parsedNumber.doubleValue());
        } catch (NumberFormatException nfe) {
            throw new FormattingException(errorMsg, nfe);
        } catch (ParseException pe) {
            throw new FormattingException(errorMsg, pe);
        }

        return value;
    }
View Full Code Here

            BigDecimal bigDecValue = (BigDecimal) value;
            bigDecValue = bigDecValue.setScale(CURRENCY_SCALE,
                    BigDecimal.ROUND_HALF_UP);
            stringValue = NumberFormat.getInstance().format(bigDecValue.doubleValue());
        } catch (IllegalArgumentException iae) {
            throw new FormattingException("Unable to format " + value +
                "as a currency value", iae);
        }

        return stringValue;
    }
View Full Code Here

        if (mode == OBJECT_TO_STRING) {
            return format(target);
        } else if (mode == STRING_TO_OBJECT) {
            return unformat((String) target);
        } else {
            throw new FormattingException("Invalid mode: " + String.valueOf(mode));
        }
    }
View Full Code Here

        SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT);
        formatter.setLenient(false);
        date = formatter.parse(target, new ParsePosition(0));

        if (date == null) {
            throw new FormattingException(errorMsg);
        }

        return date;
    }
View Full Code Here

TOP

Related Classes of de.xanders.common.exception.FormattingException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.