IllegalFormatPrecisionException.java revision adc854b798c1cfe3bfd4c27d68d5cee38ca617da
1/* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements.  See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License.  You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package java.util;
18
19/**
20 * An {@code IllegalFormatPrecisionException} will be thrown if the precision is
21 * a negative other than -1 or in other cases where precision is not supported.
22 *
23 * @see java.lang.RuntimeException
24 * @since Android 1.0
25 */
26
27public class IllegalFormatPrecisionException extends IllegalFormatException {
28    private static final long serialVersionUID = 18711008L;
29
30    private int p;
31
32    /**
33     * Constructs a new {@code IllegalFormatPrecisionException} with specified
34     * precision.
35     *
36     * @param p
37     *           the precision.
38     */
39    public IllegalFormatPrecisionException(int p) {
40        this.p = p;
41    }
42
43    /**
44     * Returns the precision associated with the exception.
45     *
46     * @return the precision.
47     */
48    public int getPrecision() {
49        return p;
50    }
51
52    /**
53     * Returns the message of the exception.
54     *
55     * @return the message of the exception.
56     */
57    @Override
58    public String getMessage() {
59        return String.valueOf(p);
60    }
61
62}
63