|
85 | 85 | * <p>
|
86 | 86 | * Here is a simple example that shows formatting and parsing:
|
87 | 87 | * <blockquote>
|
88 |
| - * <pre>{@code |
| 88 | + * {@snippet lang=java : |
89 | 89 | * double[] limits = {1,2,3,4,5,6,7};
|
90 | 90 | * String[] dayOfWeekNames = {"Sun","Mon","Tue","Wed","Thur","Fri","Sat"};
|
91 | 91 | * ChoiceFormat form = new ChoiceFormat(limits, dayOfWeekNames);
|
|
95 | 95 | * System.out.println(i + " -> " + form.format(i) + " -> "
|
96 | 96 | * + form.parse(form.format(i),status));
|
97 | 97 | * }
|
98 |
| - * }</pre> |
| 98 | + * } |
99 | 99 | * </blockquote>
|
100 | 100 | * Here is a more complex example, with a pattern format:
|
101 | 101 | * <blockquote>
|
102 |
| - * <pre>{@code |
| 102 | + * {@snippet lang=java : |
103 | 103 | * double[] filelimits = {0,1,2};
|
104 | 104 | * String[] filepart = {"are no files","is one file","are {2} files"};
|
105 | 105 | * ChoiceFormat fileform = new ChoiceFormat(filelimits, filepart);
|
|
112 | 112 | * testArgs[2] = testArgs[0];
|
113 | 113 | * System.out.println(pattform.format(testArgs));
|
114 | 114 | * }
|
115 |
| - * }</pre> |
| 115 | + * } |
116 | 116 | * </blockquote>
|
117 | 117 | * <p>
|
118 | 118 | * Specifying a pattern for ChoiceFormat objects is fairly straightforward.
|
119 | 119 | * For example:
|
120 | 120 | * <blockquote>
|
121 |
| - * <pre>{@code |
| 121 | + * {@snippet lang=java : |
122 | 122 | * ChoiceFormat fmt = new ChoiceFormat(
|
123 | 123 | * "-1#is negative| 0#is zero or fraction | 1#is one |1.0<is 1+ |2#is two |2<is more than 2.");
|
124 | 124 | * System.out.println("Formatter Pattern : " + fmt.toPattern());
|
|
133 | 133 | * System.out.println("Format with 2.1 : " + fmt.format(2.1));
|
134 | 134 | * System.out.println("Format with NaN : " + fmt.format(Double.NaN));
|
135 | 135 | * System.out.println("Format with +INF : " + fmt.format(Double.POSITIVE_INFINITY));
|
136 |
| - * }</pre> |
| 136 | + * } |
137 | 137 | * </blockquote>
|
138 | 138 | * And the output result would be like the following:
|
139 | 139 | * <blockquote>
|
|
0 commit comments